feat(backend): 앵커링 박제값 소비·가격 흔적 기록으로 채팅 경로 전환

- _resolve_anchor_price: quotation_settings.anchoring_value 스칼라 계산(float)
  삭제 → 세션 생성 시 박제된 target_anchoring_price 를 그대로 사용(협상 중
  불변). 박제 없으면 무할인 폴백(anchor=target)+WARN — 미박제라 집계 자동 제외
- 가격 입력 턴마다 sessions.last_offered_price 를 봇 메시지와 같은 트랜잭션으로
  갱신(chat_crud.update_last_offered_price) — 앵커링 표본 판정의 "가격 흔적".
  가격 쓰고 중간 이탈 → 일괄마감된 세션도 실패 표본으로 측정 가능
- sessions 모델에 anchor_rate_permille / last_offered_price /
  anchoring_adjustment_id 3컬럼 추가 (DDL 은 schedules/anchoring/schema.sql 소유)
- e2e 테스트 2종(박제값 소비·제시가 기록 / NULL 폴백) — fake agent 더블

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Fable 5 committed 2026-07-02 16:29:46 +09:00
1 parent f29e9723b0
commit fd8a2425c5
4 files changed
+231 -21

No files matched your search

+17
View File
@@ -43,6 +43,10 @@ class IChatCRUD(ABC):
) -> ErrorType:
pass
@abstractmethod
async def update_last_offered_price(self, cdb: AsyncSession, session_id, price: int) -> ErrorType:
pass
class ChatCRUD(IChatCRUD):
async def list_by_session(self, cdb: AsyncSession, session_id) -> Tuple[ErrorType, list]:
@@ -126,3 +130,16 @@ class ChatCRUD(IChatCRUD):
except Exception as ex:
LOG.e_no_callstack(ex)
return ErrorType.DB_RUN_FAILED
async def update_last_offered_price(self, cdb: AsyncSession, session_id, price: int) -> ErrorType:
"""협력사 마지막 제시가 갱신 — 가격 입력 턴의 봇 메시지 저장과 같은 트랜잭션에서 호출.
진행 중엔 매 가격 입력마다 덮어쓰고 종료 후엔 자연히 불변. 앵커링 표본 판정에서
"가격을 한 번이라도 써낸 협상"을 가르는 기준값(NULL=가격 흔적 없음 → 집계 제외).
"""
try:
query = update(sessions).where(sessions.session_id == session_id).values(last_offered_price=price)
return await DB_SESSION_MNG.add(cdb, query)
except Exception as ex:
LOG.e_no_callstack(ex)
return ErrorType.DB_RUN_FAILED