feat(search): hier section per-leaf analysis scaffold (Section-Summary-1 c1)
chunk_section_analysis 테이블(migration 286) + ORM model + pilot script. document_chunks(retrieval-hot)와 분리된 절-레벨 분석 축. domain 상속, section_type 절-전용 역할 enum, status로 skip 박제, source_content_hash로 stale 탐지. script-only(scripts mount, rebuild 불필요). LLM 0 dry-run 검증 = 5225 147 analyze + 17 skip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""chunk_section_analysis 테이블 ORM (PR-DocSrv-Hier-Section-Summary-1).
|
||||
|
||||
per-절(hier_section is_leaf) Mac mini 분석 결과 저장. document_chunks(retrieval-hot)
|
||||
와 분리된 절-레벨 분석 축. migration 286 에서 테이블 생성.
|
||||
|
||||
⚠ pilot 단계(scripts/section_summary_pilot.py)는 `./scripts` mount 로 rebuild 없이
|
||||
돌지만, 이 모델은 `app/` 이라 baked — 즉 pilot script 는 이 모델을 import 하지 않고
|
||||
raw SQL 을 쓴다. 본 모델은 (1) 스키마 문서화 (2) 향후 상시 worker 배선(별 PR, image
|
||||
rebuild 동반) 용도. 컬럼 정의는 migration 286 과 단일 진실로 동기 유지.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import BigInteger, DateTime, Float, ForeignKey, Text, text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from core.database import Base
|
||||
|
||||
|
||||
class ChunkSectionAnalysis(Base):
|
||||
__tablename__ = "chunk_section_analysis"
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
# FK CASCADE — document_chunks 에 종속된 분석 데이터(1:1). parent_id(self-FK, app-level)와 의도적 차이.
|
||||
chunk_id: Mapped[int] = mapped_column(
|
||||
BigInteger, ForeignKey("document_chunks.id", ondelete="CASCADE"), nullable=False
|
||||
)
|
||||
# summarized | skipped_tiny | failed — skip 도 행으로 박제(미처리 vs 의도 skip 구분)
|
||||
status: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
summary: Mapped[str | None] = mapped_column(Text)
|
||||
# 절-전용 역할 enum (느슨한 text, CHECK 미설정 — pilot 관찰 후 조임).
|
||||
# definition/requirement/procedure/formula/data_table/example/case_study/question/reference/overview/other
|
||||
section_type: Mapped[str | None] = mapped_column(Text)
|
||||
# doc-level taxonomy path(documents.ai_domain) 상속 스냅샷.
|
||||
domain: Mapped[str | None] = mapped_column(Text)
|
||||
confidence: Mapped[float | None] = mapped_column(Float)
|
||||
model: Mapped[str | None] = mapped_column(Text)
|
||||
prompt_version: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
# 분석 시점 leaf chunk_content_hash 스냅샷 — 원문 변경(재분해) stale 탐지.
|
||||
source_content_hash: Mapped[str | None] = mapped_column(Text)
|
||||
error: Mapped[str | None] = mapped_column(Text)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=text("now()"), nullable=False
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), server_default=text("now()"), nullable=False
|
||||
)
|
||||
|
||||
# UNIQUE(chunk_id, prompt_version) 는 migration 286 에 정의 (ORM 미반영 — 조회/upsert 는 raw SQL).
|
||||
Reference in New Issue
Block a user