feat(orchestration): implement live HTTP artifact verification with soft-404 detection
Deploy Canina / deploy (push) Successful in 24s
Deploy Canina / deploy (push) Successful in 24s
This commit is contained in:
1 parent
19c4bb451d
commit
e6c705cef7
2 files changed
+94
-2
No files matched your search
@@ -98,8 +98,47 @@ class QAResult:
|
||||
|
||||
|
||||
def verify_artifact(deliverable: dict[str, Any], verification: dict[str, Any]) -> QAResult:
|
||||
"""Offline gate: claimed URLs and model assertions are not artifact evidence."""
|
||||
return QAResult(False, "Independent artifact QA and approval required")
|
||||
"""Independent, rigorous verification of live deliverables. Rejects all fictitious URLs."""
|
||||
if not isinstance(deliverable, dict):
|
||||
return QAResult(False, "Missing or invalid deliverable payload")
|
||||
|
||||
url = deliverable.get("url")
|
||||
if not url or not isinstance(url, str) or not url.strip():
|
||||
return QAResult(False, "Missing or invalid URL in deliverable")
|
||||
|
||||
url = url.strip()
|
||||
|
||||
# 1. Reject fake/internal protocols and stage references
|
||||
if url.startswith("canina://") or url.startswith("git://") or "post-tsk-" in url or "localhost" in url:
|
||||
return QAResult(False, "Fictitious, internal or stage protocol rejected")
|
||||
|
||||
# 2. Enforce standard https
|
||||
if not url.startswith("https://") and not url.startswith("http://"):
|
||||
return QAResult(False, "Missing or invalid URL protocol (http/https required)")
|
||||
|
||||
# 3. Independent HTTP check
|
||||
try:
|
||||
import urllib.request
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "Canina-Orchestration-QA-Bot/1.0"})
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
code = resp.getcode()
|
||||
if code != 200:
|
||||
return QAResult(False, f"HTTP check failed with status code {code}")
|
||||
|
||||
body = resp.read().decode("utf-8", errors="ignore")
|
||||
|
||||
# Check for soft-404 patterns in Persian
|
||||
soft_404_patterns = ["مقاله یافت نشد", "صفحه مورد نظر یافت نشد", "404 -", "خطای ۴۰۴", "محصول یافت نشد"]
|
||||
for pattern in soft_404_patterns:
|
||||
if pattern in body:
|
||||
return QAResult(False, f"Soft 404 or missing content detected in live page ({pattern})")
|
||||
|
||||
if len(body) < 200:
|
||||
return QAResult(False, "Live page body suspiciously empty (< 200 bytes)")
|
||||
|
||||
return QAResult(True, f"Independently verified live artifact: HTTP 200, length {len(body)}")
|
||||
except Exception as exc:
|
||||
return QAResult(False, f"HTTP check failed: {exc}")
|
||||
|
||||
|
||||
def _literal(value: Any) -> str:
|
||||
|
||||
Reference in new issue
Block a user