19 Commits

Author SHA1 Message Date
windpacer
c1d228d1f6 feat: pid_equipment에 tag_dcs BOOLEAN 추가 — DCS 함수블록 vs 현장 계기 구별
## 변경 내용

### DB 스키마 (Boot DDL)
- pid_prefix_rules.tag_dcs BOOLEAN NOT NULL DEFAULT FALSE 추가
- DCS prefix 시드 마킹: FIC/TIC/PIC/LIC/FY/TY/PY/LY/FV/TV/PV/LV → tag_dcs=TRUE
- pid_equipment.tag_dcs BOOLEAN NOT NULL DEFAULT FALSE 추가
- 기존 행 backfill: instrument_type LIKE prefix% StartsWith 매칭 (FICQ/FICA 자동 포함)

### C# 도메인/서비스
- PidPrefixRule: TagDcs bool 프로퍼티 추가
- PidEquipment: TagDcs bool 프로퍼티 추가
- PidPrefixRuleDto (3개 record): TagDcs 추가
- PidExtractorService:
  - ResolveTagDcsAsync() 신규 — StartsWith 매칭, 가장 긴 prefix 우선
  - ClassifyTagClass() 재설계 — tagDcs 우선 (hasExperionLink 제거)
  - 추출 저장 시 TagDcs 채우기
  - ExportToExcelAsync() col18=DCS태그 추가 (col17=id 보호)
  - ImportFromExcelAsync() col18 읽기 (hasDcsCol 감지)
  - ApplyCategoriesToExistingAsync() 두 루프에 tag_dcs backfill 추가
  - CreatePrefixRuleAsync/UpdatePrefixRuleAsync TagDcs 저장

### Web Controller
- PidController.GetPrefixRules: tagDcs: r.TagDcs 추가

### Web UI (pid.js)
- PREFIX 그룹 각 행에 DCS/현장 배지 + 체크박스
- Add/Update body에 tagDcs 전송

### MCP/LLM
- server.py: _DCS_PREFIXES frozenset 추가
- _classify_pid_tag(): tag_dcs 반환 필드 추가
- _DB_SCHEMA: pid_equipment 테이블 설명 추가
- upsert_pid_connection: tag_dcs 파라미터 + UPDATE/INSERT SQL 수정
- sql_prompt.py: pid_equipment 테이블 추가
- prompts/plant_context.md: tag_dcs 설명 + 쿼리 예시 추가

## 설계 결정
- FT 전송기는 Experion 연결 여부와 무관하게 현장 계기 (tag_dcs=FALSE)
- tag_dcs=TRUE: prefix rule이 ground truth → system 확정
- hasExperionLink는 TagClass 결정에서 제거 (연결 정보는 ExperionTagId FK로 보존)
- compound prefix (FICQ/FICA): LIKE StartsWith 매칭으로 자동 커버

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 13:12:45 +09:00
windpacer
c7e2250bd3 feat: 트렌드 워크스페이스(ECharts) 추가 + 이벤트히스토리 sub_area 정렬
트렌드 P1 (Tab 17 "트렌드"):
- 단일 ECharts 차트 슬롯구조(trState/TR_LAYERS/trRender) — P2/P3 무중단 증분 기반
- 기능: 그룹빌더(realtime 아날로그 클릭선택)/멀티시리즈·이중축/dataZoom(좌우날짜)/
  범례표(색변경·행클릭 강조·보이는구간 통계)/보이는범위 minmax 마커/라이브 현재값/
  트립·이벤트 오버레이(/api/event-history 재사용)/100%환산/Y줌
- 백엔드: trend_group 테이블 + v_analog_points 뷰(숫자 livevalue=아날로그) +
  TrendService/TrendController(/api/trend: analog-points·groups CRUD·live) + DI
- echarts 5.5.1 로컬 번들, DTO는 [JsonPropertyName]로 camelCase 고정

이벤트히스토리 sub_area 정렬(컬럼 일치):
- event_history_table section → sub_area (DDL/인덱스/엔티티/DTO/서비스/컨트롤러/evt UI/MCP/프롬프트)
- 이력 조회 PIVOT 재작성(MAX/CASE), ft.category '계기' → 'instrument'

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 17:42:54 +09:00
windpacer
9bcba0a317 feat: 웹UI Phase 4 완료 — CSS 분리, pane 중첩 버그 수정, app.js 제거
Phase 4 — CSS 분리:
- style.css(2,230→670줄)에서 탭별 스타일을 css/<tab>.css 8개로 분할
  (t2s:437, pid:236, pb:106, hist:100, evt:50, opcsvr:14, llmchat:501, kbadmin:109)
- 크로스탭 공유 스타일(nm-*, hist-status, dt-picker 등)은 style.css 잔류
- index.html head에 11개 CSS link 태그 (1 style.css + 8 tab + 2 lib)

app.js 제거:
- index.html에서 <script src=/js/app.js> 참조 제거
- app.js → 10줄 placeholder (이미 Phase 0-3에서 모든 로직 이전 완료)

Pane wrapper 버그 수정:
- 16개 pane 파일에서 <section class=pane id=pane-xxx> wrapper 제거
- activateTab이 innerHTML로 주입 시 중첩 section + display:none 발생
- 내용이 전혀 안 보이는 문제 해결

문서 갱신:
- AGENTS.md: Frontend Architecture 섹션 추가
- 웹UI-개선플랜-byOPUS.md: Phase 0-4 완료 상태로 갱신, 결과 검증 추가

MCP:
- server.py: timestamp 정밀도 개선 등
2026-05-24 18:47:25 +09:00
windpacer
2e844abf11 feat: 운전판정 고도화 — realtime stall 수정 + 교차검증 + 단위/레인지
- ExperionRealtimeService를 단일 SuperviseAsync supervisor로 재설계:
  비블로킹 부팅, PublishingStopped/KeepAliveStopped 워치독으로 silent
  stall 감지, 30초 주기 무한 재연결, flush 루프 단일화
- RealtimeServiceStatus에 LastDataAgeSeconds/Stalled 추가, History는
  Stalled 시 스냅샷 skip
- v_plant_running_state에 진공펌프(vp-) 포함 + 교차검증 4객체
  (pump_corroboration_manual, v_pump_signal_map,
  v_plant_running_state_corroborated, v_plant_running_state_agg)
  + v_instrument_range 뷰 (boot DDL)
- MetadataLoaderService에 euhi/eulo/units 메타속성 추가
- generate_status_report에 agg 조회 연동 + sample/focus 버그 수정
- plant_context.md에 펌프 prefix(p-/vp-) + 교차검증 뷰 사용법

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 16:47:20 +09:00
windpacer
f81044c451 feat: Sub-Area(세부 Area) 분류 기능 + 포인트 삭제 시 메타데이터/이력 정리
하나의 area(P6)를 Column 단위 sub_area(P6-1/P6-2)로 분류. tag_metadata
attribute='sub_area'(EAV)에 저장, 공용 설비는 "P6-1,P6-2" 형식 + 토큰 매칭.

- 백엔드: GetSubAreaListByAreaAsync/UpdateSubAreaAsync/SeedSubAreaAsync,
  SubAreaController(GET/PUT/POST seed), SubAreaDtos
- 포인트 삭제 개선: DeleteRealtimePointAsync(purgeHistory) — 잔여 0이면
  고아 메타데이터(desc/area/sub_area) 정리, opt-in 시 history_table 영구 삭제
- MCP: find_tags(sub_area=...) + _area_or_subarea_filter('-' 포함 시 자동 토큰 매칭)
- 문서: prompts/plant_context.md, AGENTS.md, SubArea-추가플랜.md
- UI: 포인트빌더 Sub-Area 관리 카드(조회/수정/seed) + 행별 이력 삭제 체크박스

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 06:31:51 +09:00
windpacer
302183c97e feat: P&ID 연결 분석, LLM 에이전트 모드, KB 확장, MCP 서버 리팩토링
- P&ID: 연결 분석 API, Prefix 규칙 관리, 카테고리 분류, DXF 그래프 빌드
- LLM: 대화 요약, tool card 영구 보존, 시계열 차트(uPlot), 에이전트 모드
- KB: 청크 미리보기, Field Instrument Inference, 인증/Qdrant 클라이언트
- MCP: 서버 기능 확장, 파이프라인 수정, timeout 개선
- Frontend: P&ID UI, LLM UI, KB UI, OPC UA Write 탭 추가
- 설정: AGENTS.md, plant_context, README, opencode.json 업데이트
- 정리: 진단 체크리스트 문서 삭제
2026-05-21 23:36:57 +09:00
windpacer
960bda4a3c fix: P&ID 배관번호 분류 오류 수정 (power_equipment → pipings)
- _PID_LINENO_FULL_RE: 7필드 고정 regex → 5~7필드 통합 (9차 P-9107-25A-F-n 등 미매칭 수정)
- _extract_pid_dxf_fast: 레이어 이름 하드코딩 제거 → FULL_RE 매칭 우선, LINENO 계열 레이어 힌트 보조
- MatchCategoryAsync: 배관번호 regex(_pipeLineNoRe) 체크를 prefix 룰보다 먼저 실행 → P-9117-20A-F-n 등이 power_equipment로 오분류되던 문제 수정
- pump extractor 프롬프트: 배관번호 SKIP/INCLUDE 예시 추가
- DB 기존 레코드 435건 pipings로 재분류 (직접 SQL)
- .claude/settings.json: LLM 모델명 하드코딩 제거

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 10:36:30 +09:00
windpacer
d09ef95869 feat: Phase 6 보강 도구 5종 (find_tags, query_events, active_alarms, summarize_events, generate_status_report)
이벤트 중심 도구와 LLM 요약/보고서 도구를 추가해 채팅에서
"활성 알람", "교대 보고서", "이벤트 요약" 같은 운전원 요청을 처리.

신규 MCP 도구 (mcp-server/server.py):
- find_tags(query, area?, top_k):
    v_tag_summary 뷰 기반. base_tag 또는 description ILIKE 매칭.
    PV/SP/OP/설명/area 함께 반환.
- query_events(tag_name?, event_type?, area?, since?, until?, limit):
    event_history_table 필터 조회. since/until 미지정 시 최근 24h.
    event_type은 ALARM/TRIP/NORMAL/RUN/CHANGE 5종.
- active_alarms(area?, limit):
    DISTINCT ON (tagname)으로 태그별 최신 이벤트 추출 후
    ALARM/TRIP만 반환 (NORMAL 들어왔으면 자동 해제).
- summarize_events(since?, area?, event_type?, max_events, focus?):
    query_events 결과를 LLM에 넣어 한국어 6~10줄 구조화 요약
    (현황/알람/패턴/권고) + by_type/by_area 통계.
- generate_status_report(area?, hours):
    활성 알람 + 최근 이벤트 통계/표본을 LLM에 넘겨
    교대 보고서 형식(요약/알람/이벤트분석/권고) 마크다운 생성.
    윈도우 1~168시간, 기본 24시간.

공통:
- prepared statement(파라미터 바인딩)로 SQL 인젝션 방지
- SET statement_timeout = SQL_STATEMENT_TIMEOUT_MS 적용
- _DB_SCHEMA에 event_history_table 정의 추가 (NL2SQL 인지용)

시스템 프롬프트 (OllamaController):
- ToolGuideKo에 신규 5종 + search_kb + event_type 5종 명시
- run_sql 자동 가드(LIMIT/timeout) 안내 추가

검증:
- dotnet build: 경고 0건, 에러 0건
- python3 -m py_compile: OK
- import server 후 5개 도구 attribute 확인

런타임:
- mcp-server 재시작 시 신규 도구 자동 인식
- 클라이언트는 ListToolsAsync로 동적 수집 — 추가 작업 불필요

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 05:24:36 +09:00
windpacer
5a9d60e8a8 fix: Phase 5 진단 핫픽스 + Phase 6 run_sql 안전 가드
진단 보고서(plans/...phase5-사용자체크리스트.md) 기반 7건 코드 이슈
수정 + Phase 6 잔여 항목 중 최우선인 run_sql 가드 구현.

핫픽스:
- nl2sql_worker.py: _list_drawings 파싱 버그(문자열 분리) HIGH
- nl2sql_worker.py: 5개 async 함수 blocking DB 연결 → to_thread MED
- ExperionDbContext.cs: KB DDL의 {} 문자가 String.Format placeholder로
  오인되어 부팅 실패 → 별도 NpgsqlCommand 사용 HIGH
- KbIngestWorker: 단일 청크 임베딩 실패 시 전체 abort → 부분 인덱싱 LOW
- KbAuthService: 초기 비번 로그 평문 → 마스킹 + 콘솔 분리 출력 LOW
- KbQdrantClient: new HttpClient → IHttpClientFactory LOW
- OllamaController: plant_context.md 매 요청 파일 읽기 → mtime 캐시 LOW

Phase 6 — run_sql 가드:
- _validate_sql 강화: \b 단어 경계로 updated_at 오탐 제거, WITH 허용,
  TRUNCATE/COPY 추가, 다중 세미콜론 차단
- _apply_sql_guards: LIMIT 미지정 시 SELECT * FROM (...) _capped LIMIT 1000
- _execute_sql_internal: 매 호출 SET statement_timeout = 30000
- SQL_MAX_ROWS / SQL_STATEMENT_TIMEOUT_MS 환경변수화
- 응답 JSON에 row_limit 필드 추가
- nl2sql_worker.py의 _run_sql / _query_with_nl에도 동일 적용

기타:
- .gitignore: storage/ 추가 (KB 업로드 원본 디렉토리)
- opencode.json: 모델 항목을 실제 서빙 모델(Qwen3.6-27B-FP8 / 256K)로 동기화

검증:
- dotnet build: 경고 0건, 에러 0건
- python3 -m py_compile: OK
- _apply_sql_guards / _validate_sql 스모크 테스트 통과

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 05:18:06 +09:00
windpacer
908bfe151f feat: Knowledge Base RAG 시스템 + 채팅 LLM 개선 (Phase 0~5 완료)
- KB RAG 전체 파이프라인: 업로드, 파싱(xlsx/pdf/docx/text), 임베딩, Qdrant 인덱싱
- KB 관리 UI(14번 탭): 로그인, 문서 목록, 업로드, 삭제, 재인덱스
- OllamaController: 한글 시스템 프롬프트, plant_context.md 외부 파일화, SSE tool_start/tool_result 이벤트
- 프론트: 툴 실행 카드, KB 인용 링크, 표 자동 렌더, 추천 질문 칩
- nl2sql_worker: history_table.recorded_at 사용, tag_metadata 응답 개선
- DB: KB 테이블 5개 DDL + 시드, pgcrypto 확장
2026-05-13 20:22:27 +09:00
windpacer
5cacc5dbb5 feat: LLM 모델명 외부 설정 + 포인트 추가 기능
- mcp-server: 하드코딩된 모델명을 llm-model.json 기반 config.py로 외부화
- C#: AppendPointsAsync로 기존 데이터 유지하면서 포인트 추가
- C#: LlmConfigController로 LLM 모델명 조회/저장 API
- Frontend: LLM 설정 UI 카드 + 포인트 빌더에서 추가하기 버튼
2026-05-11 17:55:18 +09:00
windpacer
05e2156843 mcp-server warning clear 2026-05-09 04:28:10 +09:00
windpacer
e923aab43b opencode 로 바꾸고 작업전 커밋 2026-05-08 17:22:10 +09:00
windpacer
15c17522c8 MCP-서버 리팩토링 후 P&ID 추출 테스트전 다른 기능 확인 후 커밋 2026-05-04 10:35:13 +09:00
windpacer
a0404b1fee chore: .gitignore에 Python 캐시 및 가상환경 무시 규칙 추가 2026-05-03 03:58:23 +09:00
windpacer
f71ec310e4 feat: P&ID 그래프 파이프라인 및 MCP 서버 개선
- P&ID 그래프 파이프라인 구현 (py)
  - pid_geometric_extractor.py: 기하학적 특징 추출
  - pid_intelligent_mapper.py: 태그 매핑
  - pid_topology_builder.py: 위상 구축
  - test_pipeline_phase2.py, test_pipeline_phase3.py: 테스트

- MCP 서버 개선
  - server.py: 멀티프로세싱 지원
  - pipeline/: 분석, 추출, 매핑, 위상 모듈 추가

- C# P&ID 그래프 서비스
  - PidGraphDtos.cs: DTO 정의
  - PidGraphService.cs: 비즈니스 로직
  - PidGraphController.cs: API 컨트롤러

- OPC UA 서비스 개선
  - ExperionOpcServerService.cs
  - ExperionRealtimeService.cs
  - ExperionFastService.cs

- MCP 클라이언트 및 호스팅 서비스 개선
  - McpClient.cs
  - McpServerHostedService.cs

- 웹 UI 개선
  - pid_graph_view.html: P&ID 그래프 뷰어
  - pid-viewer.js: 뷰어 로직
  - app.js: 메인 앱
  - pid_graph.css: 스타일

- 프로젝트 설정 업데이트
  - ExperionCrawler.csproj
  - Program.cs
2026-05-03 03:50:20 +09:00
windpacer
30182bf020 feat: implement P&ID extraction and tag mapping, update MCP server and web UI 2026-05-02 14:56:04 +09:00
windpacer
fb11359b4c 2026년 4월 30일 Stable State 2026-04-30 08:16:21 +09:00
windpacer
77bdcf1f7f feat: ExperionCrawler IIoT OPC UA Data Bridge Infrastructure
Major project initialization and feature implementation:

**Core Features:**
- OPC UA client for Honeywell Experion HS R530 integration
- Real-time data streaming and history data retrieval
- Text-to-SQL query engine with TimeScaleDB
- JSON-based node configuration system
- SQLite database with migration support

**Architecture:**
- Clean architecture with Domain, Application, Infrastructure layers
- ASP.NET Core Web API frontend
- Web UI with real-time visualization
- PKI-based OPC UA authentication (TLS)

**Infrastructure Components:**
- ExperionOpcClient: OPC UA connection management
- ExperionRealtimeService: Real-time data streaming
- ExperionHistoryService: Historical data queries
- TextToSqlService: Natural language to SQL queries
- SqlValidator: SQL injection prevention

**Database:**
- TimescaleDB integration (recommended) or SQLite fallback
- Entity Framework Core with Extenstion methods
- OPCTag, KeyValue tables for data storage

**Security:**
- Certificate-based OPC UA endpoint security
- SSL/TLS encryption for database connections
- Output param binding injection prevention

**Testing:**
- Unit tests for TextToSqlService and SqlValidator
- Integration tests for Korean time range extraction

See REVIEW_REQUEST.md for detailed code review information.
2026-04-26 19:28:56 +09:00