Skip to content

feat(api): F1~F3 연동 배선 + hospitals-map + DGX 배포 토폴로지 - #79

Merged
dhkim-kr merged 2 commits into
Masterfrom
fix/backend-api-integration
Jul 25, 2026
Merged

dhkim-kr merged 2 commits into
Masterfrom
fix/backend-api-integration

Conversation

@dhkim-kr

@dhkim-kr dhkim-kr commented Jul 25, 2026

Copy link
Copy Markdown
Member

개요

apps/api BFF에 F1(session_state 왕복)~F3(survey plan/score) 연동을 배선하고, 병원맵(F-hospitals)
신규 라우트를 추가한다. safety/handoff SSOT 양방향 정렬, DGX standalone 배포 compose를 포함한다.
회귀 방지를 위한 repro/통합 테스트 스위트를 동반한다.

주의: infra/deploy/docker-compose.dgx.yml, .dockerignore는 기존 open PR #72
(deploy/backend-integration-surface)와 경로가 겹친다 — 머지 시 #72 정리 필요(아래 검증 참고).

관심사별 변경

  • session_state DB 왕복 배선: chat.py, sessions.py, session.py (ADR-046, PLAN-2026-W30-INTEG Phase 1)
  • domain_routing panic→GAD7 (Phase 2-1)
  • survey plan/score 정본화: questionnaire.py (F3)
  • safety/handoff SSOT 양방향 정렬: safety.py, handoff.py (BUG-062~066/069/075/076/080/081)
  • 병원맵 신규: api/map.py, api/v1/facilities.py, services/facilities.py, services/map_page.py, schemas/facilities.py
  • DGX standalone compose: infra/deploy/docker-compose.dgx.yml (ai-server 단독 24855)
  • 회귀 스위트: tests/repro (BUG-062081 14건) + Phase13/CVR-051/hospitals-map 통합 테스트

File changes (요약)

영역 파일 수 변경 요지 관련 doc ID
src/api, src/services (session/handoff/safety/domain_routing) 12 F1~F3 배선 + SSOT 정렬 ADR-046, BUG-062~081
src/api/map.py, v1/facilities.py, services/facilities.py, map_page.py, schemas/facilities.py 5 (신규) 병원맵 라우트 PLAN-2026-W30-INTEG
infra/deploy/docker-compose.dgx.yml (신규), docker-compose.yml 2 DGX standalone 배포 ADR-041
.env.example, pyproject.toml, scripts/seed_demo.py, core/config.py, main.py, models/* 6 설정/시드/모델 정합 BUG-057
tests/repro (신규 14) + tests/test_*.py (신규 9) + conftest.py, test_sessions.py 25 회귀·통합 테스트 BUG-062~081, CVR-051

검증

항목 근거
오프라인 스위트 318 passed (integration_status_report.md, STATE-2026-07-25)
라이브 qa 게이트 green (동일 보고서)
fresh-DB 무패치 부트스트랩 45bf331 원본 커밋

의존/머지 순서

contracts(#77) → db(#78) → backend-api(본 PR) → mobile/web. ai-server와 병행 가능하나 계약
변경(#77)이 선행되어야 함. 머지 전 #72와의 infra/deploy·.dockerignore 중복을 조율할 것.

Master(c0622ce) 리베이스 중재 (2026-07-25)

사용자 확정 결정: 병원찾기 canonical = FR-049(Master, ai-server 위임 nearby 경로).
본 PR의 FR-012(apps/api 직접 HIRA 프록시 + Kakao 지도 렌더)는 전량 폐기했다 —
services/facilities.py, services/map_page.py, api/map.py, api/v1/facilities.py,
schemas/facilities.py 및 관련 라우트 등록·테스트·.env.example
HIRA_SERVICE_KEY/KAKAO_MAP_JS_KEY/KAKAO_REST_API_KEY 항목을 제거했다. Master의
api/v1/nearby.py + services/ai_client.py::nearby_hospitals는 그대로 유지.

충돌 표면별 중재:

파일 원칙
.env.example, api/v1/__init__.py Master FR-049(nearby) 채택, FR-012(facilities) 폐기
core/config.py 양쪽 타임아웃 설정 병합(OCR/temporal/nearby/safety), FR-012 전용 필드(hira_*/kakao_map_js_key/kakao_rest_api_key) 제거
services/safety.py Master 핫라인 통일(109)과 BUG-062 CRISIS_CATEGORY_PRIORITY/to_safety_assessment(우리 쪽) 둘 다 보존
services/ai_client.py, api/v1/sessions.py 양쪽 신규 import(SurveyPlanRequest/TemporalSummarizeRequest, infer_instrument_with_caveat/_can_access_patient) 병합
main.py FR-012 전용 map_router 등록 제거

리베이스 과정에서 발견된 별도 결함도 함께 정리:

  • alembic/versions/0001_initial_auth_schema.py: is_minor GENERATED 컬럼(BUG-065)이
    리베이스 후 되살아나 있어 plain Boolean으로 재수정.
  • alembic/versions/0013_f1f3_backend_integration_schema.py 신규: 본 브랜치가 Master의
    0011/0012 이전 지점에서 분기해 자체 마이그레이션 없이 병합됐던 BUG-063
    (risk_events.status varchar(16)→32 + pending_reclassify CHECK), BUG-064
    (messages role CHECK에 'assistant' 추가), Phase 1 ADR-046 feat(scaffold): Bootstrap monorepo (pnpm + uv) + 4 app skeletons #2
    (sessions.session_state/clinical_escalation_required)을 소스와 정합.
  • tests/test_integration_rev_coupling.py: ruff I001/E501×2 수정.

검증: worktree 오프라인 스위트 173 passed / 60 skipped(BUG-058 Postgres 미연결, pre-existing)
/ 0 new failures, ruff 전체 통과(alembic 기존 7건 pre-existing 제외). packages/shared-contracts
contracts.handoff#77(feat/contracts-integration-alignment, rebase 후)이 BUG-066
report_markdown/evidence_packets shape를 이미 포함함을 git show로 확인(로컬 feat 브랜치
6906b2c와 byte-diff 없음) — addendum 불필요.

CI 참고: 본 PR 단독 CI는 Master의 contracts.safetySafetyAssessment가 아직 없어
ImportError로 실패한다(#77의 pytest는 green) — 문서화된 머지 순서(contracts(#77) 선행)상
예상된 실패이며 리베이스로 새로 만든 회귀가 아니다. #77 머지 후 재확인 필요.


스택 노트 (2026-07-25): 이 PR의 base는 feat/contracts-integration-alignment(#77)로 임시 전환되었습니다 — #77의 contracts 변경(SafetyAssessment 등)에 대한 머지-순서 의존 때문입니다. #77이 Master에 머지되면 GitHub이 이 PR을 자동으로 Master로 retarget합니다.

dhkim-kr added 2 commits July 25, 2026 23:33
session_state DB 왕복(chat.py/sessions.py/session.py, ADR-046,
PLAN-2026-W30-INTEG Phase 1), domain_routing panic->GAD7(Phase 2-1),
survey plan/score 정본화(questionnaire.py, F3), safety/handoff SSOT
양방향 정렬(BUG-062~066/069/075/076/080/081), 병원맵 신규 라우트
(api/map.py, api/v1/facilities.py, services/facilities.py,
services/map_page.py), DGX standalone compose(infra/deploy, ai-server
단독 24855) 반영. BUG repro 14건 + Phase1~3/CVR-051/hospitals-map
통합 테스트 동반.
…gration 0013 추가, ruff

Master(c0622ce) 리베이스 중재: 병원찾기는 FR-049(ai-server 위임 nearby)가 canonical —
FR-012(apps/api 직접 HIRA/facilities/map.py) 전량 제거. safety.py는 Master 핫라인
통일(109)과 BUG-062 CRISIS_CATEGORY_PRIORITY/to_safety_assessment를 함께 보존.

0001_initial_auth_schema.py: BUG-065 재발 — is_minor GENERATED 컬럼이 리베이스 후
되살아나 있어 재수정(plain Boolean, CURRENT_DATE 비-불변 표현식 제거).

0013 신규: fix/backend-api-integration이 Master 0011/0012 이전 지점에서 분기해
자체 마이그레이션 없이 병합됐던 세 항목(BUG-063 risk_events.status varchar(16)->32
+ pending_reclassify CHECK, BUG-064 messages role CHECK에 'assistant' 추가,
Phase 1 ADR-046 #2 sessions.session_state/clinical_escalation_required 컬럼)을
소스와 정합시키는 catch-up 마이그레이션.

tests/test_integration_rev_coupling.py: ruff I001(fix)/E501×2 수정.
@dhkim-kr
dhkim-kr force-pushed the fix/backend-api-integration branch from 147ead9 to 2b24906 Compare July 25, 2026 14:34
@dhkim-kr
dhkim-kr changed the base branch from feat/contracts-integration-alignment to Master July 25, 2026 14:34
@dhkim-kr
dhkim-kr merged commit 3ed0d3d into Master Jul 25, 2026
5 checks passed
dhkim-kr added a commit that referenced this pull request Jul 25, 2026
…ion collision (#89)

#78 (session_state_persistence/risk_events widen) and #85 (patient_demographics/
handoff_delivered_at) both merged into Master claiming revision IDs "0011" and
"0012" independently. Alembic's ScriptDirectory silently overwrites same-ID
entries in its revision map (last file loaded by directory-scan order wins,
`util.warn` only) rather than erroring — the losing files (0011_patient_
demographics.py, 0012_handoff_delivered_at.py by observed load order) became
permanently unreachable orphans, never applied by `alembic upgrade head` even
though src/models/patient_profile.py and src/models/handoff.py already
reference their columns.

Renumbers #78's two files 0011->0013, 0012->0014 (chronologically merged
after #85's 0011/0012 per `git show -s --format=%ci`), repoints down_revision
accordingly, and retires 0013_f1f3_backend_integration_schema.py (#79's
idempotent catch-up) as fully redundant now that 0013/0014 correctly chain.
Verified via `alembic heads --verbose`/`alembic history` (ScriptDirectory,
no DB connection): single head 0014, no "present more than once" warnings.

Not pushed — local branch only, per repo git-ops-on-request convention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant