Files
aitbc/apps/coordinator-api/DECOMPOSITION_PROGRESS.md
aitbc 745f791eda refactor: improve error handling and remove hardcoded credentials
- Changed bare except clauses to specific exception types in web3_utils.py, testing.py, messages.py, and message_storage.py
- Replaced print() calls with logger in testing.py, agent_discovery.py, compliance_agent.py, coordinator.py, trading_agent.py, keys.py, escrow.py, persistent_spending_tracker.py, sync_cli.py, and client.py
- Added logger initialization using get_logger(__name__) in compliance_agent.py, coordinator.py, trading_agent.py, keys.py, escrow.py, persistent_spending_tracker.py, and client.py
- Removed hardcoded secret
2026-05-12 17:01:57 +02:00

6.2 KiB

Coordinator-API Decomposition Progress

Phase 1: Modular Monolith Restructuring (Completed)

Week 1: Domain Boundary Identification ✓

Completed Tasks:

  • Mapped 61 routers to bounded contexts
  • Identified cross-context dependencies between routers and services
  • Created context-specific subdirectory structure for:
    • contexts/marketplace/ (routers, services, domain, storage)
    • contexts/payments/ (routers, services, domain, storage)
    • contexts/blockchain/ (routers, services, domain, storage)
    • contexts/agent_identity/ (routers, services, domain, storage)

Week 2: Service Layer Extraction ✓

Completed Tasks:

  • Extracted context-specific services to context directories:
    • Marketplace: marketplace.py, marketplace_enhanced.py, marketplace_enhanced_simple.py, global_marketplace.py, global_marketplace_integration.py
    • Payments: payments.py
    • Blockchain: blockchain.py
    • Agent Identity: (already existed in agent_identity/ directory)
  • Extracted domain models to context directories:
    • Marketplace: marketplace.py, gpu_marketplace.py, global_marketplace.py
    • Payments: payment.py
    • Agent Identity: agent_identity.py
  • Updated all imports in moved files to reference correct paths
  • Created init.py files for all context directories

Week 3: Router Organization ✓

Completed Tasks:

  • Moved routers to context directories:
    • Marketplace: marketplace.py, marketplace_gpu.py, marketplace_offers.py, global_marketplace.py, global_marketplace_integration.py
    • Payments: payments.py
    • Blockchain: blockchain.py
    • Agent Identity: agent_identity.py
  • Updated main.py to register routers from new context locations
  • All imports updated to use context-qualified paths
  • Fixed pre-existing syntax error in governance.py

Week 4: Database Schema Separation ✓

Completed Tasks:

  • Created context-specific SQLAlchemy schema files:
    • contexts/marketplace/storage/schema.py - defines marketplace_ prefix
    • contexts/payments/storage/schema.py - defines payments_ prefix
    • contexts/blockchain/storage/schema.py - defines blockchain_ prefix
    • contexts/agent_identity/storage/schema.py - defines agent_identity_ prefix
  • Updated domain models to use context-prefixed table names:
    • Marketplace: MarketplaceOffer -> marketplace_offer, MarketplaceBid -> marketplace_bid
    • Payments: JobPayment -> payments_job_payment, PaymentEscrow -> payments_escrow
    • Agent Identity: AgentIdentity -> agent_identity_identity, CrossChainMapping -> agent_identity_cross_chain_mapping, IdentityVerification -> agent_identity_verification
  • Created Alembic migration script: alembic/versions/001_context_table_prefixes.py
  • Compilation verified successfully after table name changes

Current State

Compilation Status: ✓ PASSED

  • All Python files in coordinator-api compile successfully
  • No import errors after restructuring
  • main.py successfully imports routers from context directories

Code Metrics:

  • Contexts created: 4 (marketplace, payments, blockchain, agent_identity)
  • Routers moved: 8
  • Services moved: 8
  • Domain models moved: 5
  • Import paths updated: 21 files

Next Steps (Phase 2: Microservice Extraction)

According to the decomposition plan, Phase 2 involves:

  1. Week 5: Marketplace Service Extraction
  2. Week 6: Agent Identity Service Extraction
  3. Week 7: Payments Service Extraction
  4. Week 8: Validation & Monitoring

Files Modified

Created:

  • /opt/aitbc/apps/coordinator-api/src/app/contexts/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/marketplace/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/marketplace/routers/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/marketplace/services/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/marketplace/domain/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/marketplace/storage/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/payments/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/payments/routers/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/payments/services/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/payments/domain/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/payments/storage/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/blockchain/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/blockchain/routers/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/blockchain/services/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/blockchain/domain/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/blockchain/storage/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/agent_identity/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/agent_identity/routers/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/agent_identity/services/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/agent_identity/domain/__init__.py
  • /opt/aitbc/apps/coordinator-api/src/app/contexts/agent_identity/storage/__init__.py

Modified:

  • /opt/aitbc/apps/coordinator-api/src/app/main.py - Updated router imports
  • /opt/aitbc/apps/coordinator-api/src/app/routers/governance.py - Fixed syntax error

Moved (Routers):

  • marketplace.py, marketplace_gpu.py, marketplace_offers.py, global_marketplace.py, global_marketplace_integration.py → contexts/marketplace/routers/
  • payments.py → contexts/payments/routers/
  • blockchain.py → contexts/blockchain/routers/
  • agent_identity.py → contexts/agent_identity/routers/

Moved (Services):

  • marketplace.py, marketplace_enhanced.py, marketplace_enhanced_simple.py, global_marketplace.py, global_marketplace_integration.py → contexts/marketplace/services/
  • payments.py → contexts/payments/services/
  • blockchain.py → contexts/blockchain/services/

Moved (Domain):

  • marketplace.py, gpu_marketplace.py, global_marketplace.py → contexts/marketplace/domain/
  • payment.py → contexts/payments/domain/
  • agent_identity.py → contexts/agent_identity/domain/

Import Updates:

  • All moved files updated with correct relative import paths (e.g., ...... for routers, ...... for services)