fix: temporarily disable routers to isolate Pydantic validation issue and add agent endpoints to working routers

- Comment out most routers in main.py to isolate Pydantic issue
- Keep only blockchain router enabled for testing
- Fix database warmup to use get_session() instead of SessionDep()
- Add blockchain router to __init__.py exports
- Add test endpoint to agent_router for verification
- Duplicate agent network and execution receipt endpoints in client and exchange routers as temporary workaround
This commit is contained in:
oib
2026-03-05 12:57:40 +01:00
parent 40cf275985
commit 0c090c96fa
29 changed files with 2752 additions and 183 deletions

View File

@@ -85,10 +85,10 @@ async def lifespan(app: FastAPI):
# Test database connectivity
from sqlmodel import select
from ..domain import Job
from ..storage import SessionDep
from ..storage import get_session
# Simple connectivity test using dependency injection
with SessionDep() as session:
with get_session() as session:
test_query = select(Job).limit(1)
session.exec(test_query).first()
logger.info("Database warmup completed successfully")
@@ -223,42 +223,37 @@ def create_app() -> FastAPI:
allow_headers=["*"] # Allow all headers for API keys and content types
)
app.include_router(client, prefix="/v1")
app.include_router(miner, prefix="/v1")
app.include_router(admin, prefix="/v1")
app.include_router(marketplace, prefix="/v1")
app.include_router(marketplace_gpu, prefix="/v1")
app.include_router(exchange, prefix="/v1")
app.include_router(users, prefix="/v1/users")
app.include_router(services, prefix="/v1")
app.include_router(payments, prefix="/v1")
app.include_router(marketplace_offers, prefix="/v1")
app.include_router(zk_applications.router, prefix="/v1")
app.include_router(new_governance_router, prefix="/v1")
app.include_router(community_router, prefix="/v1")
app.include_router(partners, prefix="/v1")
app.include_router(explorer, prefix="/v1")
app.include_router(web_vitals, prefix="/v1")
app.include_router(edge_gpu)
if ml_zk_proofs:
app.include_router(ml_zk_proofs)
app.include_router(marketplace_enhanced, prefix="/v1")
app.include_router(openclaw_enhanced, prefix="/v1")
app.include_router(monitoring_dashboard, prefix="/v1")
if multi_modal_rl_router:
app.include_router(multi_modal_rl_router, prefix="/v1")
app.include_router(cache_management, prefix="/v1")
app.include_router(agent_router.router, prefix="/v1/agents")
app.include_router(agent_identity, prefix="/v1")
app.include_router(global_marketplace, prefix="/v1")
app.include_router(cross_chain_integration, prefix="/v1")
app.include_router(global_marketplace_integration, prefix="/v1")
app.include_router(developer_platform, prefix="/v1")
app.include_router(governance_enhanced, prefix="/v1")
# Temporarily disable some routers to isolate the Pydantic issue
# app.include_router(client, prefix="/v1")
# app.include_router(miner, prefix="/v1")
# app.include_router(admin, prefix="/v1")
# app.include_router(marketplace, prefix="/v1")
# app.include_router(marketplace_gpu, prefix="/v1")
# app.include_router(explorer, prefix="/v1")
# app.include_router(services, prefix="/v1")
# app.include_router(users, prefix="/v1")
# app.include_router(exchange, prefix="/v1")
# app.include_router(marketplace_offers, prefix="/v1")
# app.include_router(payments, prefix="/v1")
# app.include_router(web_vitals, prefix="/v1")
# app.include_router(edge_gpu)
# if ml_zk_proofs:
# app.include_router(ml_zk_proofs)
# app.include_router(marketplace_enhanced, prefix="/v1")
# app.include_router(openclaw_enhanced, prefix="/v1")
# app.include_router(monitoring_dashboard, prefix="/v1")
# app.include_router(agent_router.router, prefix="/v1/agents")
# app.include_router(agent_identity, prefix="/v1")
# app.include_router(global_marketplace, prefix="/v1")
# app.include_router(cross_chain_integration, prefix="/v1")
# app.include_router(global_marketplace_integration, prefix="/v1")
# app.include_router(developer_platform, prefix="/v1")
# app.include_router(governance_enhanced, prefix="/v1")
# Add blockchain router for CLI compatibility
from .routers import blockchain as blockchain_router
app.include_router(blockchain_router, prefix="/v1")
# Only include blockchain for testing
app.include_router(blockchain, prefix="/v1")
# from .routers import blockchain as blockchain_router
# app.include_router(blockchain_router, prefix="/v1")
# Add Prometheus metrics endpoint
metrics_app = make_asgi_app()

View File

@@ -15,6 +15,7 @@ from .web_vitals import router as web_vitals
from .edge_gpu import router as edge_gpu
from .cache_management import router as cache_management
from .agent_identity import router as agent_identity
from .blockchain import router as blockchain
# from .registry import router as registry
__all__ = [
@@ -33,6 +34,7 @@ __all__ = [
"edge_gpu",
"cache_management",
"agent_identity",
"blockchain",
"global_marketplace",
"cross_chain_integration",
"global_marketplace_integration",

View File

@@ -418,6 +418,12 @@ async def get_execution_logs(
raise HTTPException(status_code=500, detail=str(e))
@router.get("/test")
async def test_endpoint():
"""Test endpoint to verify router is working"""
return {"message": "Agent router is working", "timestamp": datetime.utcnow().isoformat()}
@router.post("/networks", response_model=dict, status_code=201)
async def create_agent_network(
network_data: dict,

View File

@@ -1,6 +1,7 @@
from fastapi import APIRouter, Depends, HTTPException, status, Request
from slowapi import Limiter
from slowapi.util import get_remote_address
from datetime import datetime
from ..deps import require_client_key
from ..schemas import JobCreate, JobView, JobResult, JobPaymentCreate
@@ -266,3 +267,70 @@ async def get_blocks(
"offset": offset,
"error": f"Failed to fetch blocks: {str(e)}"
}
# Temporary agent endpoints added to client router until agent router issue is resolved
@router.post("/agents/networks", response_model=dict, status_code=201)
async def create_agent_network(network_data: dict):
"""Create a new agent network for collaborative processing"""
try:
# Validate required fields
if not network_data.get("name"):
raise HTTPException(status_code=400, detail="Network name is required")
if not network_data.get("agents"):
raise HTTPException(status_code=400, detail="Agent list is required")
# Create network record (simplified for now)
network_id = f"network_{datetime.utcnow().strftime('%Y%m%d_%H%M%S')}"
network_response = {
"id": network_id,
"name": network_data["name"],
"description": network_data.get("description", ""),
"agents": network_data["agents"],
"coordination_strategy": network_data.get("coordination", "centralized"),
"status": "active",
"created_at": datetime.utcnow().isoformat(),
"owner_id": "temp_user"
}
return network_response
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.get("/agents/executions/{execution_id}/receipt")
async def get_execution_receipt(execution_id: str):
"""Get verifiable receipt for completed execution"""
try:
# For now, return a mock receipt since the full execution system isn't implemented
receipt_data = {
"execution_id": execution_id,
"workflow_id": f"workflow_{execution_id}",
"status": "completed",
"receipt_id": f"receipt_{execution_id}",
"miner_signature": "0xmock_signature_placeholder",
"coordinator_attestations": [
{
"coordinator_id": "coordinator_1",
"signature": "0xmock_attestation_1",
"timestamp": datetime.utcnow().isoformat()
}
],
"minted_amount": 1000,
"recorded_at": datetime.utcnow().isoformat(),
"verified": True,
"block_hash": "0xmock_block_hash",
"transaction_hash": "0xmock_tx_hash"
}
return receipt_data
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

View File

@@ -4,6 +4,7 @@ Bitcoin Exchange Router for AITBC
from typing import Dict, Any
from fastapi import APIRouter, HTTPException, BackgroundTasks, Request
from datetime import datetime
import uuid
import time
import json
@@ -214,3 +215,80 @@ async def monitor_payment(payment_id: str):
# For demo, we'll wait for manual confirmation
await asyncio.sleep(30) # Check every 30 seconds
# Agent endpoints temporarily added to exchange router
@router.get("/agents/test")
async def test_agent_endpoint():
"""Test endpoint to verify agent routes are working"""
return {"message": "Agent routes are working", "timestamp": datetime.utcnow().isoformat()}
@router.post("/agents/networks", response_model=dict, status_code=201)
async def create_agent_network(network_data: dict):
"""Create a new agent network for collaborative processing"""
try:
# Validate required fields
if not network_data.get("name"):
raise HTTPException(status_code=400, detail="Network name is required")
if not network_data.get("agents"):
raise HTTPException(status_code=400, detail="Agent list is required")
# Create network record (simplified for now)
network_id = f"network_{datetime.utcnow().strftime('%Y%m%d_%H%M%S')}"
network_response = {
"id": network_id,
"name": network_data["name"],
"description": network_data.get("description", ""),
"agents": network_data["agents"],
"coordination_strategy": network_data.get("coordination", "centralized"),
"status": "active",
"created_at": datetime.utcnow().isoformat(),
"owner_id": "temp_user"
}
logger.info(f"Created agent network: {network_id}")
return network_response
except HTTPException:
raise
except Exception as e:
logger.error(f"Failed to create agent network: {e}")
raise HTTPException(status_code=500, detail=str(e))
@router.get("/agents/executions/{execution_id}/receipt")
async def get_execution_receipt(execution_id: str):
"""Get verifiable receipt for completed execution"""
try:
# For now, return a mock receipt since the full execution system isn't implemented
receipt_data = {
"execution_id": execution_id,
"workflow_id": f"workflow_{execution_id}",
"status": "completed",
"receipt_id": f"receipt_{execution_id}",
"miner_signature": "0xmock_signature_placeholder",
"coordinator_attestations": [
{
"coordinator_id": "coordinator_1",
"signature": "0xmock_attestation_1",
"timestamp": datetime.utcnow().isoformat()
}
],
"minted_amount": 1000,
"recorded_at": datetime.utcnow().isoformat(),
"verified": True,
"block_hash": "0xmock_block_hash",
"transaction_hash": "0xmock_tx_hash"
}
logger.info(f"Generated receipt for execution: {execution_id}")
return receipt_data
except Exception as e:
logger.error(f"Failed to get execution receipt: {e}")
raise HTTPException(status_code=500, detail=str(e))

View File

@@ -97,6 +97,7 @@ def get_session():
with Session(engine) as session:
yield session
# Create SessionDep as Annotated type - this should work with proper imports
SessionDep = Annotated[Session, Depends(get_session)]