feat(wall): 建材首次索要改双要(WhatsApp+邮箱一起要)+已留资话术渠道中性+缺失渠道补问通用化
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -101,7 +101,7 @@ def test_split_sentences_decimal_not_split():
|
||||
|
||||
|
||||
def test_pivot_contact_aware():
|
||||
assert "WhatsApp?" in pivot_for("how much?")
|
||||
assert "WhatsApp" in pivot_for("how much?")
|
||||
assert "WhatsApp?" not in pivot_for("how much?", has_contact=True)
|
||||
assert "客户经理" in pivot_for("多少钱")
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ def test_reminder_cc_pending_overrides_d6():
|
||||
assert "+254 712 345678" in text
|
||||
assert "is that right" in text.lower() # 回显确认句(模板同源句式)
|
||||
assert "回显补全后的完整号码" in text # D6 改写后的 cc 豁免条款
|
||||
assert "缺失渠道仅可按轻补指引提一次" in text # 防自锁改写在位
|
||||
assert "缺失渠道(号码或邮箱)仅可再礼貌提一次" in text # 防自锁改写在位
|
||||
|
||||
|
||||
def test_affirm_confirms_no_resend(async_db, monkeypatch):
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"""双要话术静态锚(spec 2026-11-02-jiancai-dual-contact-ask §5.3)。
|
||||
|
||||
首次索要联系方式 = WhatsApp+邮箱一起要(双要);已留资后的确认/收尾话术
|
||||
渠道中性(邮箱-only 客户不再听到"发到你 WhatsApp")。wall.json 侧锚在
|
||||
本文件前半,system.md/company_facts.md 侧锚在后半(Task 2 追加)。
|
||||
"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
SEED = Path(__file__).resolve().parents[1] / "seed_profiles" / "jiancai"
|
||||
|
||||
|
||||
def _wall() -> dict:
|
||||
return json.loads((SEED / "wall.json").read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
# ---- wall 侧 ----
|
||||
|
||||
def test_deflections_dual_ask_all_languages():
|
||||
w = _wall()
|
||||
assert any("and email" in s for s in w["deflections"]["en"])
|
||||
assert any("和邮箱" in s for s in w["deflections"]["zh"])
|
||||
assert any("y tu correo" in s for s in w["deflections"]["es"])
|
||||
|
||||
|
||||
def test_pivots_dual_ask_all_languages():
|
||||
w = _wall()
|
||||
assert "and email" in w["pivots"]["en"][0]
|
||||
assert "和邮箱" in w["pivots"]["zh"][0]
|
||||
assert "y tu correo" in w["pivots"]["es"][0]
|
||||
|
||||
|
||||
def test_post_contact_templates_channel_neutral():
|
||||
"""已留资确认/收尾模板不含渠道词(三语逐一钉死,防只用 en 子串漏检)。"""
|
||||
w = _wall()
|
||||
for group in ("deflections_contact", "pivots_contact"):
|
||||
for lang, items in w[group].items():
|
||||
for s in items:
|
||||
assert "whatsapp" not in s.lower(), (group, lang, s)
|
||||
assert "whatsapp" not in w["no_contact"]["already"].lower()
|
||||
|
||||
|
||||
def test_app_reverse_ask_dual_and_synced():
|
||||
"""App 反向留资句双要,且 no_contact.app = contact_ask.app 逐字句同源。"""
|
||||
w = _wall()
|
||||
app = w["no_contact"]["app"]
|
||||
assert "and email" in app
|
||||
assert app in w["reminders"]["contact_ask"]["app"]
|
||||
@@ -451,7 +451,7 @@ def test_reminder_boundary_branches_on_contact_state():
|
||||
text = ConversationManager._build_context_reminder(raw, "多少钱", [])
|
||||
assert "职能边界" in text and "禁止再索要联系方式" in text
|
||||
# Task 3 防自锁改写: 本分支尾部补缺失渠道豁免(子串由尾补保留,非 :651 改写行)
|
||||
assert "缺失渠道可按轻补指引提一次" in text
|
||||
assert "缺失渠道——号码或邮箱——可再礼貌提一次" in text
|
||||
# 未留联系方式: 引导留资
|
||||
text2 = ConversationManager._build_context_reminder({}, "多少钱", [])
|
||||
assert "职能边界" in text2 and "禁止再索要联系方式" not in text2
|
||||
@@ -678,19 +678,19 @@ def test_reminder_app_contact_ask_gated_by_existing_contact():
|
||||
text = ConversationManager._build_context_reminder(
|
||||
raw, "how can I contact you", [], source="app")
|
||||
assert "Drop your WhatsApp" not in text
|
||||
assert "reach out to you at your WhatsApp" in text # 已留资版逐字脚本
|
||||
assert "reach out to you shortly with the full quote" in text # 已留资版逐字脚本
|
||||
|
||||
|
||||
def test_reminder_app_contact_ask_confirmed_allows_missing_channel_once():
|
||||
# Task 3 收尾: contact_note app+已留资分支的第三处禁令同步改写(禁令集完整)。
|
||||
# 防空转设计: 双渠道齐 → 轻补 note 不注入;消息无价格词 → 边界分支不渲染;
|
||||
# 此时"缺失渠道可按轻补指引提一次"只能来自该分支改写文本
|
||||
# (:651 版是"仅可按",不构成子串)。
|
||||
# 此时"缺失渠道——号码或邮箱——可再礼貌提一次"只能来自该分支改写文本
|
||||
# (forbidden 版是"仅可",不构成子串)。
|
||||
raw = {"联系方式": {"whatsapp": "+254712345678", "email": "a@b.com"}}
|
||||
text = ConversationManager._build_context_reminder(
|
||||
raw, "how can I contact you?", [], source="app")
|
||||
assert "reach out to you at your WhatsApp" in text # 已留资版逐字脚本在场
|
||||
assert "缺失渠道可按轻补指引提一次" in text # 第三处禁令改写钉死
|
||||
assert "reach out to you shortly with the full quote" in text # 已留资版逐字脚本在场
|
||||
assert "缺失渠道——号码或邮箱——可再礼貌提一次" in text # 第三处禁令改写钉死
|
||||
assert "email address would help too" not in text # 双渠道齐→无轻补注入(防空转)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user