"""공유 도면 — **생산자를 실제로 태워서** 본다 (Codex BLOCK 2, 2026-09-19).

앞서 쓴 시험은 합치는 루프를 **시험 안에 다시 써서** 봤다. 그래서 「첫 그룹의
정의만 쓰고 다른 그룹의 씬 원문이 안 실린다」는 것을 못 봤다.

실측: `fp_container_interior` 를 두 그룹이 쓰는데 **장소가 서로 다르다** —
L166 `container_home` 과 L170 `container_living_space`. 그런 것을 소리 없이
합치면 잘못된 공간 하나로 「성공」 처리된다.
"""
from __future__ import annotations

import inspect


def test_producer_merges_specs_not_first_wins():
    from app.core.steps import floor_plan_prompt_step as m

    src = inspect.getsource(m.FloorPlanPromptStep)
    assert "fp_specs" in src, "정의를 모으지 않는다"
    assert "merged[\"scope\"]" in src or 'merged["scope"]' in src, (
        "범위 설명을 첫 그룹 것만 쓴다")
    assert "same_identity" in src, "신원이 갈렸는지 판정하지 않는다"


def test_producer_uses_every_group_scene_text():
    from app.core.steps import floor_plan_prompt_step as m

    src = inspect.getsource(m.FloorPlanPromptStep)
    assert "all_group_ids" in src, "한 그룹 씬 원문만 싣는다"
    assert "group_scene_cache.get(_gid" in src


def test_identity_mismatch_is_left_for_a_human():
    """신원이 다른 공유 도면은 **산출에 남아야** 한다 — 로그만 남기면 안 보인다."""
    from app.core.steps import floor_plan_prompt_step as m

    src = inspect.getsource(m.FloorPlanPromptStep)
    assert '"shared_floor_plans": shared_fp_diag' in src
    assert "logger.warning" in src
