V10.574 串接型錄可比覆核與來源治理橋接
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s

This commit is contained in:
OoO
2026-06-03 10:42:41 +08:00
parent 930ad402ff
commit e78b2720d9
17 changed files with 963 additions and 36 deletions

View File

@@ -83,7 +83,7 @@ def test_competitor_coverage_counts_only_active_product_intersection():
"def _fetch_manual_review_summary", 1
)[0]
assert "coverage:v11" in source
assert "coverage:v12" in source
assert "CATALOG_COMPARABLE_SCORE_FLOOR" in source
assert "rescore_accepted_count" in coverage_source
assert "(SELECT COUNT(*) FROM valid_competitor) AS valid_matches" not in coverage_source
@@ -104,8 +104,10 @@ def test_competitor_coverage_counts_only_active_product_intersection():
assert "\"decision_support_count\": decision_support_count" in coverage_source
assert "\"decision_support_rate\": round(decision_support_count / max(active, 1) * 100, 1)" in coverage_source
assert "\"catalog_comparable_count\": catalog_comparable_count" in coverage_source
assert "CATALOG_COMPARABLE_SIGNAL_REASONS" in coverage_source
assert "CATALOG_COMPARABLE_BLOCK_REASONS" in coverage_source
assert "_catalog_comparable_sql(\"la\")" in coverage_source
assert "CATALOG_COMPARABLE_SIGNAL_REASONS" in source
assert "CATALOG_COMPARABLE_IDENTITY_REASONS" in source
assert "CATALOG_COMPARABLE_BLOCK_REASONS" in source
assert "\"identity_coverage_matches\": valid" in coverage_source
assert "\"manual_closed_count\": manual_closed_count" in coverage_source
assert "\"last_decision_ready_crawled_at\": last_decision_ready_crawled_at" in coverage_source
@@ -186,6 +188,7 @@ def test_competitor_review_queue_is_canonical_unit_price_handoff():
def test_competitor_review_filters_split_low_score_operational_buckets():
from services.competitor_intel_repository import REVIEW_STATUS_FILTER_GROUPS
assert REVIEW_STATUS_FILTER_GROUPS["catalog_comparable"] == ("true_low_confidence",)
assert REVIEW_STATUS_FILTER_GROUPS["recoverable_low_score"] == ("recoverable_low_score",)
assert REVIEW_STATUS_FILTER_GROUPS["true_low_confidence"] == ("true_low_confidence",)
assert REVIEW_STATUS_FILTER_GROUPS["legacy_low_score"] == ("low_score", "refresh_low_score")
@@ -197,6 +200,41 @@ def test_competitor_review_filters_split_low_score_operational_buckets():
}
def test_catalog_comparable_review_item_keeps_exact_match_guardrail():
from services.competitor_intel_repository import _format_competitor_review_item
item = _format_competitor_review_item({
"sku": "CAT-001",
"name": "DASHING DIVA Gloss Gel 美甲片 月影柔霧",
"momo_price": 699,
"attempt_status": "true_low_confidence",
"catalog_comparable": True,
"candidate_count": 3,
"best_competitor_product_id": "DABC-CATALOG",
"best_competitor_product_name": "DASHING DIVA Gloss Gel 美甲片 月影柔霧 任選",
"best_competitor_price": 599,
"best_match_score": 0.912,
"match_diagnostic_json": {
"match_type": "comparable",
"price_basis": "manual_review",
"alert_tier": "identity_review",
"reasons": [
"strong_product_line_match",
"variant_selection_review",
],
},
})
assert item["review_bucket"] == "catalog_comparable"
assert item["status_label"] == "型錄/任選可比"
assert "型錄、任選" in item["action_label"]
envelope = item["decision_envelope"]
assert envelope["recommended_action"]["action"] == "review_catalog_comparable"
assert envelope["guardrails"]["can_auto_execute"] is False
assert envelope["guardrails"]["catalog_comparable"] is True
assert any(evidence["metric"] == "catalog_comparable" for evidence in envelope["evidence"])
def test_competitor_review_reasons_prefer_json_payload_labels():
from services.competitor_intel_repository import _format_competitor_review_item