docs + V4 catalog + samples + Phase Q legacy 보존
전체 26 files (20 추가 + 6 수정), 10507 insertions. Phase Z 문서 : - docs/architecture/PHASE-Z-CHANGE-LOG.md (신설) — axis-by-axis 의사결정 history (newest-on-top). Step 7-A 부터 6 entry 박힘 + 2026-05-08 / 2026-05-08 #2 (compat 매트릭스 폐기 / 6-B 폐기 / F14 표현 정정 / label gate policy 분리). - docs/architecture/PHASE-Z-PIPELINE-OVERVIEW.md (수정) — Step 5/6/9 Gap note append (구조 무변, append-only). 6-B 폐기 사실 + Refinement F. - docs/architecture/PHASE-Z-PIPELINE-STATUS-BOARD.md (수정) — snapshot date 2026-05-08 갱신. §3 핵심 missing item 5 (Step 5/6/9 boundary axis breakdown + 폐기 기록). §6 한 줄 갱신 — 다음 axis 후보 A~F. Project root docs : - PLAN.md / PROGRESS.md / README.md (수정) — 토큰 체계 / 폴더 구조 / 설계 문서 / 역할 분리 반영. - IMPROVEMENT-REDESIGN.md (신설) — Phase Z 설계 핵심 문서. - PROCESS_OVERVIEW.html (신설) — 파이프라인 개요 시각. - docs/tasks/* (신설) — Phase Z task 문서. V4 catalog (Phase Z runtime 필수 의존성) : - tests/matching/v4_full32_result.yaml (신설, 4888 줄) — V4 매칭 결과 32 frame × 10 MDX section. lookup_v4_match() / lookup_v4_candidates() 가 본 파일 read. Phase Z runtime 이 *없으면 즉시 abort* — clone 후 즉시 동작 가능 보장. Samples : - samples/mdx_batch/04.mdx (신설) — MDX04 기본 sample. - samples/mdx/04. DX 지연 요인.mdx (신설) — MDX04 원본. Phase Q legacy 보존 (별 axis "Phase Q audit & salvage" 영역) : - src/block_matcher_tfidf.py / catalog_blocks.py / frame_extractor.py / pipeline_v2.py — Phase Q (옛 파이프라인) src 신규 untracked 파일들. Phase Z runtime 와 의존성 0. Phase Q audit axis 에서 검토 예정. - scripts/eval_block_matcher.py / fetch_all_frame_screenshots.py / match_17_units_my_matcher.py / match_mdx_strict.py / match_mdx_to_frames_tfidf.py / ocr_augment_texts.py / run_pipeline_v2.py / previews/ — Phase Q 작업 시 사용한 옛 script. 같이 보존. - run_mdx03_pipeline.py (수정) — Phase Q 진입점 (no flag) + Phase Z 진입점 (--phase-z2 flag) 동시 wrapper. Phase Z 만 사용 시 `python -m src.phase_z2_pipeline samples/mdx_batch/03.mdx <run_id>` 직접 호출. 비-scope : - tests/matching/ (v4_full32_result.yaml 외 ~63MB) — V4 진화 history / reports / DECK / ATTACH. Phase Q audit axis 에서 검토. - tests/pipeline/ (~15MB) — pipeline data. Phase Q audit 영역. - templates/catalog/blocks.yaml — 옛 block catalog. Phase Q audit. - templates/phase_z2/frames/ — 옛 frame partial 위치. Phase Q audit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
69
src/catalog_blocks.py
Normal file
69
src/catalog_blocks.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""새 catalog 로더.
|
||||
|
||||
기존 templates/catalog.yaml과 별도로,
|
||||
templates/catalog/blocks.yaml을 로드하는 모듈.
|
||||
|
||||
기존 코드는 건드리지 않음.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def load_blocks_catalog(
|
||||
path: str | Path = "templates/catalog/blocks.yaml",
|
||||
) -> list[dict]:
|
||||
"""blocks.yaml 로드.
|
||||
|
||||
Returns:
|
||||
[{"id": "prerequisites-3col",
|
||||
"structure_type": "3col-parallel",
|
||||
"keywords": ["필수", "요건", ...],
|
||||
"slots": ["sub_title", "body", "bullets"],
|
||||
"recipe_compat": ["direct_fit", "parallel_cluster"],
|
||||
"not_for": ["long_table"],
|
||||
"template": "blocks/structures/prerequisites-3col.html",
|
||||
"when": "3개 병렬 비교"}, ...]
|
||||
"""
|
||||
import yaml
|
||||
path = Path(path)
|
||||
if not path.exists():
|
||||
logger.warning(f"[catalog] blocks.yaml 없음: {path}")
|
||||
return []
|
||||
|
||||
try:
|
||||
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
blocks = data if isinstance(data, list) else data.get("blocks", [])
|
||||
logger.info(f"[catalog] {len(blocks)}개 블록 로드: {path}")
|
||||
return blocks
|
||||
except Exception as e:
|
||||
logger.error(f"[catalog] 로드 실패: {e}")
|
||||
return []
|
||||
|
||||
|
||||
def find_block_by_id(
|
||||
blocks: list[dict],
|
||||
block_id: str,
|
||||
) -> dict | None:
|
||||
"""ID로 블록 찾기."""
|
||||
return next((b for b in blocks if b.get("id") == block_id), None)
|
||||
|
||||
|
||||
def filter_blocks_by_structure(
|
||||
blocks: list[dict],
|
||||
structure_type: str,
|
||||
) -> list[dict]:
|
||||
"""structure_type으로 필터링."""
|
||||
return [b for b in blocks if b.get("structure_type") == structure_type]
|
||||
|
||||
|
||||
def filter_blocks_by_recipe(
|
||||
blocks: list[dict],
|
||||
recipe: str,
|
||||
) -> list[dict]:
|
||||
"""recipe 호환 블록 필터링."""
|
||||
return [b for b in blocks if recipe in b.get("recipe_compat", [])]
|
||||
Reference in New Issue
Block a user