Some checks failed
CI / build (push) Failing after 3s
PHASE 2.3 (AUDIT-2026-Q3.md):
Task 1 — Wire-in Wave 3 (1 router mounted, 2 deferred):
- app.routers.unified_scanner_router mounted at /api/v2/scanner/* (2 routes:
POST /api/v2/scanner/token/scan, POST /api/v2/scanner/wallet/scan).
Refactored prefix from /api/v2 -> /api/v2/scanner to avoid future conflicts
with the v1 /api/v1/scanner/ stub.
- app.routers.unified_wallet_scanner DEFERRED (no router APIRouter attribute;
library module consumed by unified_scanner_router via get_wallet_scanner()).
- app.routers.admin_extensions DEFERRED (DORMANT per audit; 25 routes at
/api/v1/admin/* would shadow /api/v1/admin/alerts_webhook).
Task 2 — Archive 136 dead-code files to app/_archive/legacy_2026_07/:
- 73 routers in app/routers/ (reach graph showed zero reach into mount.py).
- 63 flat app/*.py (domain modules never imported by live code).
- 1 file RESTORED post-archive: app/routers/x402_bridge_health.py (caught by
tests/unit/test_bridge_health.py which directly imports it; reach graph
considered tests/ only as transitive reach — to be patched in next cycle).
Forced-LIVE (NOT archived per user directive):
- app/ai_pipeline_v3.py (3 importers in audit window, importers themselves DEAD)
- app/splade_bm25.py (LIVE via app.rag_service)
- app/wallet_manager_v2.py (LIVE via x402_enforcement, x402_tools, sweep_all, sweep_now)
- app/crypto_embeddings.py (NOT in audit ARCHIVE list; heavy import graph)
Verification (forward-import closure from mount.py + main.py + factory.py + lifespan.py):
- imports = 348 app.* modules
- reached = 194 files reachable from roots
- archive set = audit_dead (186) - reached - forced_live (4) - test_live (1) = 136
- Net delta: 136 files moved, 44,932 LOC reduction, 293->295 active routes (+2 from Wave 3)
pyproject.toml updates:
- setuptools.packages.find: added exclude for app._archive*
- ruff.extend-exclude: added "app/_archive/"
- mypy.exclude: added "app/_archive/"
Smoke test: pytest tests/ — 817 passed, 3 pre-existing failures unchanged
(0 new failures; 0 routes lost; all 4 forced-LIVE files still importable).
Restoration: git mv app/_archive/legacy_2026_07/<name>.py <original-path>
and add the import to app/mount.py ROUTER_MODULES.
Refs: AUDIT-2026-Q3.md /home/dev/pry/rmi-final-deadcode-2026-07-06.md
96 lines
2.8 KiB
Python
96 lines
2.8 KiB
Python
from fastapi import APIRouter
|
|
|
|
router = APIRouter(prefix="/api/v1/protection", tags=["protection"])
|
|
|
|
|
|
@router.get("/health")
|
|
async def check_health() -> dict:
|
|
"""Check health of all protection modules.
|
|
|
|
Returns:
|
|
{"status": "ok|degraded|down", "modules": {...}}
|
|
"""
|
|
status = "ok"
|
|
modules = {
|
|
"rag": {"status": "ok"},
|
|
"scanner": {"status": "ok"},
|
|
"blocklist": {"status": "ok"},
|
|
"wallet_labels": {"status": "ok"},
|
|
"entity_intel": {"status": "ok"},
|
|
}
|
|
|
|
# Check RAG
|
|
try:
|
|
from app.rag_service import search_similar
|
|
|
|
await search_similar("health_check", "known_scams", limit=1, min_similarity=0.1)
|
|
except Exception as e:
|
|
modules["rag"]["status"] = "down"
|
|
modules["rag"]["error"] = str(e)
|
|
status = "degraded"
|
|
|
|
# Check scanner
|
|
try:
|
|
from app.degen_security_scanner import DegenSecurityScanner
|
|
|
|
scanner = DegenSecurityScanner()
|
|
await scanner.scan_token("health_check", "solana")
|
|
except Exception as e:
|
|
modules["scanner"]["status"] = "down"
|
|
modules["scanner"]["error"] = str(e)
|
|
status = "degraded"
|
|
|
|
# Check blocklist
|
|
try:
|
|
await get_blocklist() # noqa: F821 -- pre-existing bug, see fix(f821) tracking issue
|
|
except Exception as e:
|
|
modules["blocklist"]["status"] = "down"
|
|
modules["blocklist"]["error"] = str(e)
|
|
status = "degraded"
|
|
|
|
# Check wallet labels
|
|
try:
|
|
from app.wallet_label_loader import lookup_wallet_label
|
|
|
|
lookup_wallet_label("health_check", "solana")
|
|
except Exception as e:
|
|
modules["wallet_labels"]["status"] = "down"
|
|
modules["wallet_labels"]["error"] = str(e)
|
|
status = "degraded"
|
|
|
|
# Check entity intel
|
|
try:
|
|
from app.entity_intel import get_entity_intel
|
|
|
|
await get_entity_intel("health_check", "solana")
|
|
except Exception as e:
|
|
modules["entity_intel"]["status"] = "down"
|
|
modules["entity_intel"]["error"] = str(e)
|
|
status = "degraded"
|
|
|
|
return {"status": status, "modules": modules}
|
|
|
|
|
|
async def check_url(url: str) -> dict:
|
|
"""Stub for URL checking."""
|
|
return {"safe": True, "url": url}
|
|
|
|
|
|
async def check_wallet(address: str, chain: str = "solana") -> dict:
|
|
"""Stub for wallet checking."""
|
|
return {"safe": True, "address": address, "chain": chain}
|
|
|
|
|
|
async def check_token(address: str, chain: str = "solana") -> dict:
|
|
"""Stub for token checking."""
|
|
return {"safe": True, "address": address, "chain": chain, "risk_score": 0, "flags": []}
|
|
|
|
|
|
async def get_blocklist_domains() -> dict:
|
|
"""Stub for getting blocklist domains."""
|
|
return {"domains": [], "last_updated": "2024-01-01T00:00:00Z"}
|
|
|
|
|
|
async def get_protection_health() -> dict:
|
|
"""Stub for getting protection health."""
|
|
return {"status": "ok", "modules": {"protection": "ok"}}
|