Type: Feature
Priority: P1 (High)
Labels: feature, backend, billing, blockchain
Epic: #XXX (Epic: Complete Remaining Features)
Estimated Effort: 3-4 weeks
Description
Implement AdaptivePricingService for adaptive cost calculation per service and BridgeCreditVerificationService for cross-chain credit verification via bridge.
Current State:
- ✅ RollingCreditsService fully implemented
- ✅ CreditBalance and CreditTransaction models with credit types exist
- ✅ CreditToken.sol contract exists
- ❌ AdaptivePricingService missing (mentioned in rules but service doesn't exist)
- ❌ BridgeCreditVerificationService missing
Target State:
- Adaptive cost calculation per service
- Server-set fees for server transactions
- Adaptive fees for client-side calls
- Bridge-based credit verification
- Credit conversion via bridge
Related Plan
dev/ROLLING_CREDITS_SUBSCRIPTION_PLAN.md - Complete implementation plan (Projects 3 & 4)
Sub-Tasks
Backend Services
Integration
API Endpoints
Acceptance Criteria
- ✅ Adaptive cost calculation works for all workflow types
- ✅ Pricing factors (complexity, volume, tier, time, organization) applied correctly
- ✅ Server fees set and retrieved correctly
- ✅ Client call fees calculated adaptively
- ✅ Credit usage verified on organization blockchain via bridge
- ✅ Credit conversion via bridge works
- ✅ Balance synchronization from blockchain works
- ✅ Integration with RollingCreditsService complete
Dependencies
- RollingCreditsService (✅ Already implemented)
- CreditBalance/CreditTransaction models (✅ Already implemented)
- CreditToken.sol contract (✅ Already implemented)
- CrossChainService (⚠️ May need to be created - see Organization plan)
- BlockchainRouterService (⚠️ May need to be created - see Organization plan)
Testing
Created: 2026-01-26
Status: Open
Type: Feature
Priority: P1 (High)
Labels:
feature,backend,billing,blockchainEpic: #XXX (Epic: Complete Remaining Features)
Estimated Effort: 3-4 weeks
Description
Implement AdaptivePricingService for adaptive cost calculation per service and BridgeCreditVerificationService for cross-chain credit verification via bridge.
Current State:
Target State:
Related Plan
dev/ROLLING_CREDITS_SUBSCRIPTION_PLAN.md- Complete implementation plan (Projects 3 & 4)Sub-Tasks
Backend Services
Create AdaptivePricingService (
app/services/adaptive_pricing_service.py)calculate_adaptive_cost()- Calculate adaptive cost for workflow_get_pricing_factors()- Get pricing factors (complexity, volume, tier, time of day, organization)get_server_fee()- Get server-set fee for server transaction/callget_client_call_fee()- Get adaptive fee for client-side callCreate BridgeCreditVerificationService (
app/services/bridge_credit_verification_service.py)verify_credit_usage()- Verify credit usage on organization blockchain via bridgeconvert_credits_via_bridge()- Convert credits from one type to another via bridge_update_credits_via_bridge()- Update credits on organization blockchain via bridge_get_blockchain_credit_balance()- Get credit balance from blockchain_sync_balance_from_blockchain()- Sync credit balance from blockchain to databaseIntegration
Integrate AdaptivePricingService with RollingCreditsService
Integrate BridgeCreditVerificationService with RollingCreditsService
API Endpoints
Create Adaptive Pricing API (
app/api/pricing_routes.py)GET /api/pricing/calculate- Calculate adaptive cost for workflowGET /api/pricing/server-fee- Get server fee for serviceGET /api/pricing/client-fee- Get client call feeCreate Bridge Verification API (
app/api/bridge_verification_routes.py)POST /api/bridge-verification/verify- Verify credit usagePOST /api/bridge-verification/convert- Convert credits via bridgePOST /api/bridge-verification/sync- Sync balance from blockchainAcceptance Criteria
Dependencies
Testing
Created: 2026-01-26
Status: Open