- src: phase_z2 composition/mapper/pipeline/placement_planner/retry, ai_fallback(prompts/schema/validate), mdx_text_atoms 신규 - Front: PipelineTracePanel 신규, FramePanel/SlideCanvas/Home/designAgentApi 등 갱신 + 테스트 4종 추가 - templates/phase_z2: catalog(component_expansion_registry, node_slot_mapping 신규), frames, families, slide_base 갱신 - tests/matching: phase2~26 매칭 실험 스크립트·리포트·온톨로지 전체 (미커밋 진행분) - tests: b4_v4 evidence, task5~28.5 시리즈, regression(imp95 baseline) 등 신규 테스트 대량 추가 - docs/reference: MDX 구조 인벤토리, MDX→Frame 구조 계약 문서 - scripts: mdx 계약/parity/coverage/viewport 체크, gitea comment, run sync 유틸 - .gitignore: tmp*.json, chromedriver, .orchestrator, *.pkl, Front_test* 등 임시/스냅샷 제외 미완성 작업의 보존용 스냅샷 커밋 (2026-07-02) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
80 lines
2.7 KiB
Python
80 lines
2.7 KiB
Python
from phase_z2_composition import CompositionUnit
|
|
from phase_z2_pipeline import (
|
|
GENERIC_FALLBACK_FRAME_ID,
|
|
GENERIC_FALLBACK_FRAME_TEMPLATE_ID,
|
|
MdxSection,
|
|
_collapse_units_to_parent_sections,
|
|
)
|
|
|
|
|
|
def _unit(source_ids, template="child_frame", score=1.0):
|
|
return CompositionUnit(
|
|
source_section_ids=list(source_ids),
|
|
merge_type="single",
|
|
frame_template_id=template,
|
|
frame_id="frame",
|
|
frame_number=1,
|
|
confidence=0.9,
|
|
label="light_edit",
|
|
phase_z_status="matched_zone",
|
|
raw_content="child raw",
|
|
title="child title",
|
|
score=score,
|
|
)
|
|
|
|
|
|
def test_task14_child_sections_collapse_to_parent_units():
|
|
parent_sections = [
|
|
MdxSection("05-1", 1, "S1 title", "S1 raw"),
|
|
MdxSection("05-2", 2, "S2 title", "S2 raw"),
|
|
]
|
|
aligned_sections = [
|
|
MdxSection("05-1", 1, "S1 title", "S1 raw"),
|
|
MdxSection("05-2-sub-1", 2, "child 1", "child 1 raw"),
|
|
MdxSection("05-2-sub-2", 2, "child 2", "child 2 raw"),
|
|
]
|
|
units = [
|
|
_unit(["05-1"], template="frame_a", score=0.5),
|
|
_unit(["05-2-sub-1", "05-2-sub-2"], template="frame_b", score=0.7),
|
|
]
|
|
|
|
collapsed, status_sections, audit = _collapse_units_to_parent_sections(
|
|
units,
|
|
aligned_sections,
|
|
parent_sections,
|
|
fallback_template_id=GENERIC_FALLBACK_FRAME_TEMPLATE_ID,
|
|
fallback_frame_id=GENERIC_FALLBACK_FRAME_ID,
|
|
)
|
|
|
|
assert audit["applied"] is True
|
|
assert [s.section_id for s in status_sections] == ["05-1", "05-2"]
|
|
assert [u.source_section_ids for u in collapsed] == [["05-1"], ["05-2"]]
|
|
assert collapsed[1].merge_type == "parent_section_unit"
|
|
assert collapsed[1].title == "S2 title"
|
|
assert collapsed[1].raw_content == "S2 raw"
|
|
assert (
|
|
collapsed[1].rationale["task14_parent_section_unit"]["aligned_child_section_ids"]
|
|
== ["05-2-sub-1", "05-2-sub-2"]
|
|
)
|
|
|
|
|
|
def test_task14_adds_parent_fallback_when_group_uncovered():
|
|
parent_sections = [MdxSection("04-2", 2, "S2 title", "S2 raw")]
|
|
aligned_sections = [
|
|
MdxSection("04-2-sub-1", 2, "child 1", "child 1 raw"),
|
|
MdxSection("04-2-sub-2", 2, "child 2", "child 2 raw"),
|
|
]
|
|
|
|
collapsed, status_sections, audit = _collapse_units_to_parent_sections(
|
|
[],
|
|
aligned_sections,
|
|
parent_sections,
|
|
fallback_template_id=GENERIC_FALLBACK_FRAME_TEMPLATE_ID,
|
|
fallback_frame_id=GENERIC_FALLBACK_FRAME_ID,
|
|
)
|
|
|
|
assert [s.section_id for s in status_sections] == ["04-2"]
|
|
assert [u.source_section_ids for u in collapsed] == [["04-2"]]
|
|
assert collapsed[0].merge_type == "parent_no_drop_fallback"
|
|
assert audit["added_fallbacks"][0]["parent_section_id"] == "04-2"
|