fix(telegram): support matrix source contracts in container
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m15s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

This commit is contained in:
Your Name
2026-07-02 19:07:33 +08:00
parent e2447d49a0
commit a0acc2d5f2
3 changed files with 63 additions and 7 deletions

View File

@@ -355,29 +355,29 @@ def _require_safe_boundaries(*payloads: dict[str, Any]) -> None:
def _inspect_source_contract(repo_root: Path) -> dict[str, int | bool]:
source_checks = {
"telegram_gateway_mirror_present": (
repo_root / "apps/api/src/services/telegram_gateway.py",
"apps/api/src/services/telegram_gateway.py",
"_mirror_outbound_message",
),
"telegram_gateway_record_outbound_present": (
repo_root / "apps/api/src/services/telegram_gateway.py",
"apps/api/src/services/telegram_gateway.py",
"record_outbound_message",
),
"ai_alert_card_metadata_present": (
repo_root / "apps/api/src/services/telegram_gateway.py",
"apps/api/src/services/telegram_gateway.py",
"ai_automation_alert_card_mirror_v1",
),
"outbound_message_model_present": (
repo_root / "apps/api/src/db/awooop_models.py",
"apps/api/src/db/awooop_models.py",
"__tablename__ = \"awooop_outbound_message\"",
),
"ai_alert_card_delivery_readback_endpoint_present": (
repo_root / "apps/api/src/api/v1/platform/operator_runs.py",
"apps/api/src/api/v1/platform/operator_runs.py",
"/runs/ai-alert-cards",
),
}
result: dict[str, int | bool] = {}
for key, (path, marker) in source_checks.items():
text = path.read_text(encoding="utf-8", errors="replace") if path.exists() else ""
for key, (relative_path, marker) in source_checks.items():
text = _read_source_contract_text(repo_root, relative_path)
present = marker in text
result[key] = present
if key == "ai_alert_card_delivery_readback_endpoint_present":
@@ -389,6 +389,18 @@ def _inspect_source_contract(repo_root: Path) -> dict[str, int | bool]:
return result
def _read_source_contract_text(repo_root: Path, relative_path: str) -> str:
candidates = [repo_root / relative_path]
api_prefix = "apps/api/"
if relative_path.startswith(api_prefix):
candidates.append(repo_root / relative_path.removeprefix(api_prefix))
for path in candidates:
if path.exists():
return path.read_text(encoding="utf-8", errors="replace")
return ""
def _next_priority_action(
*,
api_direct_gap_count: int,