Attach decision envelopes to review queue
This commit is contained in:
@@ -177,6 +177,46 @@ def test_competitor_review_reasons_prefer_json_payload_labels():
|
||||
"nail_tool_function_conflict",
|
||||
"schick_razor_line_conflict",
|
||||
]
|
||||
envelope = item["decision_envelope"]
|
||||
assert envelope["decision_type"] == "pchome_match_review"
|
||||
assert envelope["subject"]["sku"] == "SKU-1"
|
||||
assert envelope["subject"]["competitor_product_id"] == "DABC123"
|
||||
assert envelope["guardrails"]["can_auto_execute"] is False
|
||||
assert envelope["guardrails"]["data_quality"] == "partial"
|
||||
assert envelope["guardrails"]["match_type"] == "no_match"
|
||||
assert envelope["recommended_action"]["requires_hitl"] is True
|
||||
assert envelope["recommended_action"]["action"] == "verify_or_reject_identity"
|
||||
assert any(evidence["metric"] == "reasons" for evidence in envelope["evidence"])
|
||||
|
||||
|
||||
def test_rescore_accepted_review_item_has_actionable_decision_envelope():
|
||||
from services.competitor_intel_repository import _format_competitor_review_item
|
||||
|
||||
item = _format_competitor_review_item({
|
||||
"sku": "10922465",
|
||||
"name": "【Herbacin 德國小甘菊】小甘菊1號護手霜20ml",
|
||||
"momo_price": 99,
|
||||
"attempt_status": "rescore_accepted_current",
|
||||
"candidate_count": 1,
|
||||
"best_competitor_product_id": "DDAO4C-A79050612",
|
||||
"best_competitor_product_name": "小甘菊經典護手霜20ml",
|
||||
"best_competitor_price": 89,
|
||||
"best_match_score": 0.872,
|
||||
"match_diagnostic_json": {
|
||||
"match_type": "exact",
|
||||
"price_basis": "total_price",
|
||||
"alert_tier": "identity_review",
|
||||
"reasons": ["focused_exact_identity_herbacin_classic_hand_cream_20ml_brandless"],
|
||||
},
|
||||
})
|
||||
|
||||
envelope = item["decision_envelope"]
|
||||
assert envelope["severity"] in {"P1", "P2"}
|
||||
assert envelope["recommended_action"]["action"] == "review_accept_identity"
|
||||
assert envelope["guardrails"]["data_quality"] == "complete"
|
||||
assert envelope["expected_impact"]["gap_amount"] == 10
|
||||
assert envelope["expected_impact"]["candidate_gap_pct"] == 11.2
|
||||
assert any(evidence["metric"] == "candidate_gap_pct" for evidence in envelope["evidence"])
|
||||
|
||||
|
||||
def test_competitor_ppt_prompt_uses_neutral_ewooc_viewpoint():
|
||||
|
||||
Reference in New Issue
Block a user