# [InsuRo P0-1] Drive 프록시 — Gap 1 보완: FCPA drive_file_id 일관성

## allowed_resources

```yaml
allowed_resources:
  paths:
    - "server/main.py"
    - "server/tests/**"
    - "supabase/migrations/**"
  forbidden_paths:
    - ".env"
    - ".env.*"
    - ".github/**"
  commands:
    - "pytest"
    - "python3 -m py_compile"
    - "python3 -c"
  merge_policy: "tiered"
  ttl_hours: 24
```

## 배경
Drive 프록시 Phase 1.5(task-2928)는 main 머지 대기 중. Codex 교차검증에서 **Gap 1**: FCPA 가이드 업로드 경로가 `fcpa_config.pdf_url`만 저장하고 `drive_file_id`를 안 채움. 현재 FCPA 인가(`server/main.py:5915` 부근)는 `pdf_url`에서 실시간 file_id 추출해 매칭하므로 **기능상 무해**하나, 다른 테이블(newsletters/premium_data/policy_analyses)과 **일관성**을 위해 FCPA도 `drive_file_id`로 통일한다. (본 보완으로 Codex 합의 → 머지 GO 예정)

## 수정 범위 (소규모 — task-2928 worktree 위에 이어서 or 신규 브랜치)
1. **마이그레이션**: `fcpa_config`에 `drive_file_id text` 컬럼 추가(`ADD COLUMN IF NOT EXISTS`) + 기존 `pdf_url`에서 백필(`substring(pdf_url from '/file/d/([^/]+)')`) + 인덱스.
2. **FCPA 업로드 배선**(`server/main.py:958` 부근, `fcpa_config` upsert 시): `pdf_url`과 함께 `drive_file_id = gdrive.extract_drive_file_id(drive_url)` 저장.
3. **인가 로직 통일**(`server/main.py:5915` 부근, FCPA 등급 판정): `drive_file_id == file_id` 매칭 우선, 없으면 기존 `pdf_url` 추출 매칭 **폴백 유지**(하위호환).

## 검증
1. 유닛: FCPA 업로드 후 `drive_file_id` 채워짐 / file-ticket FCPA 등급 인가가 drive_file_id·pdf_url 양쪽으로 동작.
2. 회귀 0 (task-2928 테스트 포함 통과). ★ 단 `test_consultation_history_get.py::test_cors_fail_closed_when_ext_origin_unset`는 **base에서도 실패하는 pre-existing 환경테스트**이므로 회귀 아님(무시).
3. 마이그레이션 백필 검증.

## 배포
- 마이그레이션 있음 → ANU가 Management API로 적용(코드 머지 전). 코드 머지=ANU, systemd 재배포=ANU. finalize-only.

## 완료 보고
수정 파일 diff · 마이그레이션 · 업로드 배선 · 인가 폴백 · 회귀 결과 · callback.