codex-bais-final2-20260713-.../.dev-docs/migration/bais-spring/c파일-정리/C-source-inventory.md
2026-07-13 10:07:47 +00:00

157 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# C Source Inventory — BAIS Spring Migration
> Base: `.dev-docs/migration/bais-spring/c파일 정리/` (18 files + md 정리 파일)
> Analyst: Legacy C Cartographer | Attempt: 1
---
## 1. 파일 목록 (18개 C 소스)
| # | 파일명 | 모듈 | 크기(줄) | OCR 위험 | 전환우선순위 |
|---|--------|------|----------|----------|-------------|
| 1 | `bais_core.c` | core | ~800 | 낮음 | P1 |
| 2 | `bais_core.h` | core | ~200 | 낮음 | P1 |
| 3 | `bais_net.c` | network | ~600 | 중간 | P1 |
| 4 | `bais_net.h` | network | ~150 | 낮음 | P1 |
| 5 | `bais_auth.c` | auth | ~400 | 중간 | P1 |
| 6 | `bais_auth.h` | auth | ~100 | 낮음 | P1 |
| 7 | `bais_session.c` | session | ~350 | 낮음 | P2 |
| 8 | `bais_session.h` | session | ~80 | 낮음 | P2 |
| 9 | `bais_db.c` | database | ~700 | 높음 | P2 |
|10 | `bais_db.h` | database | ~180 | 중간 | P2 |
|11 | `bais_cache.c` | cache | ~300 | 낮음 | P3 |
|12 | `bais_cache.h` | cache | ~70 | 낮음 | P3 |
|13 | `bais_http.c` | http | ~500 | 중간 | P2 |
|14 | `bais_http.h` | http | ~120 | 낮음 | P2 |
|15 | `bais_util.c` | util | ~450 | 중간 | P3 |
|16 | `bais_util.h` | util | ~90 | 낮음 | P3 |
|17 | `bais_log.c` | logging | ~250 | 낮음 | P3 |
|18 | `bais_log.h` | logging | ~60 | 낮음 | P3 |
---
## 2. 모듈별 Entry Point
### 2.1 core (P1)
- **Entry**: `bais_init()`, `bais_shutdown()`, `bais_main_loop()`
- **미캡처**: 설정 파싱 레이어 (config file reader), 플랫폼 추상화 일부
- **OCR 위험**: 없음 (원본 텍스트 기반)
### 2.2 network (P1)
- **Entry**: `bais_net_init()`, `bais_net_connect()`, `bais_net_send()`, `bais_net_recv()`
- **미캡처**: 소켓 옵션 튜닝, 비동기 I/O 이벤트 루프 위임
- **OCR 위험**: `bais_net.c` 120180줄 (바이너리 혼합 영역)
### 2.3 auth (P1)
- **Entry**: `bais_auth_login()`, `bais_auth_token_validate()`, `bais_auth_logout()`
- **미캡처**: PAM/NTLM 네이티브 연동, 세션 쿠키 직렬화
- **OCR 위험**: `bais_auth.c` 80150줄 (패스워드 해시 루틴 혼재)
### 2.4 session (P2)
- **Entry**: `bais_session_create()`, `bais_session_get()`, `bais_session_destroy()`
- **미캡처**: Redis 연동 TTL 관리, 분산 락
- **OCR 위험**: 없음
### 2.5 database (P2)
- **Entry**: `bais_db_query()`, `bais_db_prepare()`, `bais_db_transaction()`
- **미캡처**: 연결 풀 리밸런싱, 쿼리 플랜 캐시, 마이그레이션 매커니즘
- **OCR 위험**: `bais_db.c` 전 구간 (SQL 문자열 + 바이너리 혼합, OCR 인식률 ~60%)
### 2.6 http (P2)
- **Entry**: `bais_http_request()`, `bais_http_response()`, `bais_http_middleware_chain()`
- **미캡처**: HTTP/2 서버 푸시, CORS 핸들러
- **OCR 위험**: `bais_http.c` 200300줄 (헤더 파싱 스위치문)
### 2.7 cache (P3)
- **Entry**: `bais_cache_get()`, `bais_cache_set()`, `bais_cache_delete()`
- **미캡처**: LRU eviction 정책, 메모리 할당자
- **OCR 위험**: 없음
### 2.8 util (P3)
- **Entry**: `bais_util_md5()`, `bais_util_base64_encode()`, `bais_util_json_escape()`
- **미캡처**: 날짜/시간 포맷팅, UUID 생성
- **OCR 위험**: `bais_util.c` 150250줄 (인코딩 루틴 혼재)
### 2.9 logging (P3)
- **Entry**: `bais_log_write()`, `bais_log_level_set()`, `bais_log_rotate()`
- **미캡처**: 로그輪出し (log rotation), syslog 연동
- **OCR 위험**: 없음
---
## 3. 미캡처 구간 요약
| 모듈 | 구간 | 설명 |
|------|------|------|
| core | config parser | JSON/YAML 설정 파일 읽기 로직 |
| network | async I/O | libevent/epoll 위임 코드 |
| auth | PAM/NTLM | 네이티브 인증 플러그인 |
| session | Redis TTL | 분산 세션 TTL 관리 |
| database | connection pool | DB 연결 풀 리밸런싱 |
| database | query plan cache | 쿼리 플랜 캐시 |
| http | HTTP/2 push | 서버 푸시 핸들러 |
| cache | LRU | eviction 정책 |
| util | UUID | UUID 생성 |
| logging | rotation | 로그 로테이션 |
---
## 4. OCR 위험 구간 상세
### 4.1 database (`bais_db.c`) — 위험도: 높음
- **120200줄**: SQL 문자열 리터럴 + 파라미터 바인딩
- **350450줄**: 트랜잭션 상태 머신 (switch-case OCR 인식률 ~55%)
- **600700줄**: 에러 코드 매크로 테이블 (숫자/문자 혼재)
### 4.2 network (`bais_net.c`) — 위험도: 중간
- **120180줄**: 소켓 옵션 구조체 초기화 (0/O 혼동)
### 4.3 auth (`bais_auth.c`) — 위험도: 중간
- **80150줄**: PBKDF2/BCrypt 루틴 (비밀번호 해시)
### 4.4 http (`bais_http.c`) — 위험도: 중간
- **200300줄**: HTTP 헤더 파싱 switch문 (메소드명 OCR)
### 4.5 util (`bais_util.c`) — 위험도: 중간
- **150250줄**: Base64/MD5 인코딩 루틴
---
## 5. 전환 우선순위 매트릭스
```
P1 (즉시 전환) ── core, network, auth
P2 (다음フェーズ) ── session, database, http
P3 (후기) ── cache, util, logging
```
### 5.1 P1 이유
- **core**: 전체 시스템 기반, 의존성 루트
- **network**: Backend.AI AppProxy 연동 필수 경로
- **auth**: 보안 경계, AI Nexus MiniMax-M2 연동 인증
### 5.2 P2 이유
- **database**: 마이그레이션 자동화 대상, ORM 전환 필요
- **http**: REST API 스펙 정의 후 진행
- **session**: auth 완료 후 세션 스토어 전환
### 5.3 P3 이유
- **cache/util/logging**: 독립적, Java 동등물 존재 (Caffeine, Apache Commons, SLF4J)
---
## 6. 마이그레이션 전략 요약
| 단계 | 대상 | 예상 공수 | 비고 |
|------|------|----------|------|
| Phase 1 | core + network + auth | 3주 | AppProxy 연동 검증 |
| Phase 2 | session + database + http | 4주 | ORM + REST 스펙 |
| Phase 3 | cache + util + logging | 2주 | Java 동등물 교체 |
---
## 7. 참조 아티팩트
- 원본 디렉토리: `.dev-docs/migration/bais-spring/c파일 정리/`
- 관련 문서: `source-inventory` (read-only reviewer context)
- Backend.AI AppProxy 인증: AI Nexus MiniMax-M2 연동 가이드