Merge branch 'main' into design/frontend
# Conflicts: # postgres-init/00-init.sql # postgres-init/01-schema_202607061714.sql # postgres-init/01-schema_202607070958.sql # postgres-init/04-alter_202607070958.sql
This commit is contained in:
commit
d2710250e0
54 files changed
+2497
-359
No files matched your search
@@ -32,15 +32,17 @@ class _AnchorAgent(IAgentClient):
|
||||
"""결정론적 더블: 서비스안내(오프닝) → 가격 입력 요청 → 합의 종료.
|
||||
|
||||
앵커보다 높은 가격이면 같은 step 을 반복(마지막 제시가 덮어쓰기 검증용).
|
||||
매 턴 수신한 ctx.anchor_price 를 기록해 backend 의 앵커 해석을 관찰한다.
|
||||
(script 에 앵커가 보이는 건 테스트 관찰 편의일 뿐 — 실제 agent 는 비노출.)
|
||||
앵커 해석(박제값 소비/무할인 폴백)은 agent 가 DB 에서 직접 수행하도록 이관됐다
|
||||
(NegotiationContextLoader — agent tests/test_context_loader.py 가 검증). 여기 더블은
|
||||
자체 앵커 상수로 수락 여부만 판정하고, backend 가 보내는 ctx.target_price 를 관찰한다.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.seen_anchors: list[int] = []
|
||||
def __init__(self, anchor: int = ANCHOR):
|
||||
self.anchor = anchor
|
||||
self.seen_targets: list[int] = []
|
||||
|
||||
async def chat(self, session_id, user_input, ctx) -> AgentTurn:
|
||||
self.seen_anchors.append(ctx.anchor_price)
|
||||
self.seen_targets.append(ctx.target_price)
|
||||
sid = session_id or "fake-session"
|
||||
if user_input is None: # 오프닝(턴0)
|
||||
return AgentTurn(session_id=sid, step="서비스안내", client_step="서비스안내",
|
||||
@@ -48,10 +50,10 @@ class _AnchorAgent(IAgentClient):
|
||||
input_options=["네, 시작할게요"])
|
||||
if ctx.client_step == "서비스안내":
|
||||
return AgentTurn(session_id=sid, step="기존가격제시", client_step="기존가격제시",
|
||||
script=f"저희가 제안드리는 첫 목표 가격은 {ctx.anchor_price}원입니다. "
|
||||
script=f"저희가 제안드리는 첫 목표 가격은 {self.anchor}원입니다. "
|
||||
f"제안하실 가격을 입력해 주세요.", input_mode="price")
|
||||
price = _parse_price(user_input)
|
||||
if price is not None and price <= ctx.anchor_price:
|
||||
if price is not None and price <= self.anchor:
|
||||
return AgentTurn(session_id=sid, step="협상종료", client_step="협상종료",
|
||||
script=f"{price:,}원으로 합의되었습니다.", chat_end=True, outcome="success")
|
||||
return AgentTurn(session_id=sid, step="기존가격제시", client_step="기존가격제시",
|
||||
@@ -159,7 +161,7 @@ async def test_snapshot_consumed_and_last_offer_recorded(client, db_engine, anch
|
||||
assert r.status_code == 200 and r.json()["message"]["step"] == "기존가격제시"
|
||||
row = await _anchor_columns(db_engine, sid)
|
||||
assert row.last_offer_price is None
|
||||
assert _fake_agent.seen_anchors[-1] == ANCHOR # backend 가 박제값을 그대로 전달
|
||||
assert _fake_agent.seen_targets[-1] == TARGET # backend 로컬 컨텍스트(target) 전달 확인
|
||||
|
||||
r = await _send(client, token, sid, "99,500", "price") # 앵커 초과 → 같은 step 반복
|
||||
assert r.json()["message"]["step"] == "기존가격제시"
|
||||
@@ -175,7 +177,8 @@ async def test_snapshot_consumed_and_last_offer_recorded(client, db_engine, anch
|
||||
assert (row.anchoring_price, row.anchoring_value) == (ANCHOR, 10) # 박제 불변
|
||||
|
||||
|
||||
# ── 폴백 경로: 박제 NULL → 무할인(anchor=target) + 미박제 유지 ──
|
||||
# ── 폴백 경로: 박제 NULL 세션도 backend 채팅 경로가 정상 동작 + 미박제 유지 ──
|
||||
# (무할인 폴백 anchor=target 자체는 agent NegotiationContextLoader 가 수행/검증 — agent 테스트 소관)
|
||||
async def test_null_snapshot_falls_back_to_target(client, db_engine, anchor_seed, _fake_agent):
|
||||
sid = str(anchor_seed["sids"]["N"])
|
||||
token = await _login_token(client)
|
||||
@@ -183,11 +186,13 @@ async def test_null_snapshot_falls_back_to_target(client, db_engine, anchor_seed
|
||||
await _messages(client, token, sid)
|
||||
r = await _send(client, token, sid, "네, 시작할게요")
|
||||
assert r.json()["message"]["step"] == "기존가격제시"
|
||||
assert _fake_agent.seen_anchors[-1] == TARGET # 무할인 폴백: anchor = target
|
||||
|
||||
r = await _send(client, token, sid, "97,000", "price") # 가격 입력(폴백 앵커 이하 → 종료)
|
||||
r = await _send(client, token, sid, "97,000", "price") # 가격 입력(더블 앵커 이하 → 종료)
|
||||
assert r.json()["session_status"] == 3
|
||||
row = await _anchor_columns(db_engine, sid)
|
||||
assert (row.anchoring_price, row.anchoring_value) == (None, None) # 미박제 유지(집계 제외 조건)
|
||||
assert row.bid_price == 97_000
|
||||
row = await _anchor_columns(db_engine, sid)
|
||||
assert row.anchoring_price is None # backend 는 박제하지 않음(앵커 없음 → 집계 제외)
|
||||
assert row.anchoring_value is None
|
||||
assert row.last_offer_price == 97_000 # 가격 흔적 기록은 정상 동작
|
||||
Reference in new issue
Block a user