{"slug":"strategy/business-strategy/WIRING_ROADMAP","title":"IntegrateWise Wiring Roadmap","section":"strategy","sectionLabel":"Strategy","status":"unclassified","type":"document","path":"strategy/business-strategy/WIRING_ROADMAP.mdx","bytes":12730,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"## IntegrateWise Wiring Roadmap\n\n> **Tier C — Historical.** This document is a point-in-time snapshot preserved for reference. For current architecture, see [CANONICAL_PLATFORM_ARCHITECTURE.md](../architecture/CANONICAL_PLATFORM_ARCHITECTURE.md).\n\n**Objective**: Connect all implemented services into a unified platform\n\n---\n\n## Critical Path: Request-to-Response Wiring\n\n### Phase 1A: Gateway Request Entry Point\n\n**Current State**\n\n- Gateway service exists with routing logic\n- ADK middleware detects capability type\n- Projection facades are wired\n- **Missing**: Actually calling the appropriate service for each request\n\n**What Needs to Be Wired**\n\n```\nUser Request\n    ↓\nGateway (index.ts) receives request\n    ↓\nIdentity layer (auth.ts) - JWT validation ✓\n    ↓\nADK middleware (adk-middleware.ts) - detects capability type ✓\n    ↓\n[MISSING] Route to appropriate service based on capability type\n    ├── If ADK capability → Check ADK registry\n    ├── If MCP capability → Route to mcp-connector\n    ├── If Native capability → Route to direct service\n    └── If ADX capability → Route to intelligence (agent)\n    ↓\n[MISSING] Call selected service with tenant context\n    ↓\n[MISSING] Aggregate response and return to client\n```\n\n**Specific Files to Wire**\n\n- `services/gateway/src/index.ts` - Add service dispatcher logic\n- `services/gateway/src/adk-middleware.ts` - Hook up capability selection\n- `services/gateway/src/projection-facade-wiring.ts` - Actually call facades\n\n**Success Criteria**\n\n- Single POST to gateway routes correctly to at least 3 different services\n- Response includes proper tenant context\n- Error handling propagates correctly\n\n---\n\n### Phase 1B: Database Connectivity\n\n**Current State**\n\n- D1 schema defined in `services/loader/schema.sql`\n- Services have database query logic written\n- **Missing**: Connection string setup, migration execution, query execution\n\n**What Needs to Be Wired**\n\n```\nService wants data\n    ↓\nQuery constructed in service code\n    ↓\n[MISSING] Get D1 database connection from Cloudflare bindings\n    ↓\n[MISSING] Execute query with proper tenant scoping\n    ↓\n[MISSING] Return results with error handling\n    ↓\nCache in KV if needed\n```\n\n**Specific Files to Wire**\n\n- Each service's database queries (e.g., `services/tenants/src/rbac.ts`)\n- Environment configuration for D1 connection\n- Migration script for schema.sql\n\n**Success Criteria**\n\n- Services can read/write to D1\n- Queries are tenant-scoped\n- Data survives between requests\n\n---\n\n### Phase 1C: HITL Orchestrator Integration\n\n**Current State**\n\n- HITL orchestrator fully implemented (867 lines, tested)\n- Intelligence service exists for proposal generation\n- Govern service exists for approvals\n- Pipeline service exists for execution\n- **Missing**: Gateway → HITL → Intelligence → Govern → Pipeline chain\n\n**What Needs to Be Wired**\n\n```\nHuman submits intent via gateway\n    ↓\n[MISSING] Gateway calls HITL orchestrator\n    ↓\nHITL.captureIntent() - stores request ✓\n    ↓\n[MISSING] HITL calls intelligence.generateProposal()\n    ↓\nIntelligence generates reasoning + proposal ✓\n    ↓\n[MISSING] Return proposal to user for approval\n    ↓\n[MISSING] Wait for human approval (via gateway callback)\n    ↓\nHuman submits approval via gateway\n    ↓\n[MISSING] Gateway calls HITL.submitApproval()\n    ↓\n[MISSING] HITL calls pipeline.execute()\n    ↓\nPipeline executes the approved action ✓\n    ↓\n[MISSING] Capture results for learning\n```\n\n**Specific Files to Wire**\n\n- `services/gateway/src/index.ts` - Add HITL endpoints\n- `services/gateway/src/hitl-orchestrator.ts` - Hook into intelligence/govern/pipeline\n- `services/intelligence/src/index.ts` - Accept proposal requests\n\n**Success Criteria**\n\n- Complete HITL flow works end-to-end\n- Human can approve/reject proposals\n- Execution happens and results are captured\n\n---\n\n### Phase 1D: Continuity Context Chains\n\n**Current State**\n\n- Continuity service retrieves memory + context\n- Twin orchestrator manages per-user context\n- Knowledge service provides semantic knowledge\n- **Missing**: Request → context retrieval → enrichment → capability execution\n\n**What Needs to Be Wired**\n\n```\nGateway receives request\n    ↓\n[MISSING] Call continuity.getContext(userId)\n    ↓\nContinuity calls:\n    - Twin orchestrator for user state\n    - Knowledge for semantic knowledge\n    - Hermes for episodic memory\n    ↓\nContext assembled with:\n    - User preferences\n    - Recent actions\n    - Relevant knowledge\n    - Current task state\n    ↓\n[MISSING] Attach context to request as it passes through services\n    ↓\nEach service uses context for decisions\n```\n\n**Specific Files to Wire**\n\n- `services/gateway/src/index.ts` - Request enrichment\n- `services/continuity/src/index.ts` - Context aggregation\n- `services/twin-orchestrator/src/index.ts` - Twin state retrieval\n\n**Success Criteria**\n\n- Requests include user context\n- Context is consistent across service calls\n- Context improves decision-making\n\n---\n\n## Critical Path: Service-to-Service Bridges\n\n### Phase 2A: Intelligence ↔ Knowledge Bridge\n\n**What Needs to Be Wired**\n\n```\nIntelligence agent needs knowledge\n    ↓\n[MISSING] Intelligence calls knowledge service\n    ↓\nKnowledge performs semantic search\n    ↓\nResults returned to intelligence\n    ↓\nIntelligence integrates into reasoning\n```\n\n**Specific Wiring**\n\n- `services/intelligence/src/index.ts` - Add knowledge.query() calls\n- `services/knowledge/src/index.ts` - Add semantic search API\n- Inter-service authentication tokens\n\n---\n\n### Phase 2B: Pipeline ↔ Connector Bridge\n\n**What Needs to Be Wired**\n\n```\nPipeline needs to execute action on external system\n    ↓\n[MISSING] Pipeline calls connector service\n    ↓\nConnector selects appropriate provider\n    ↓\nConnector calls MCP/OAuth connector\n    ↓\nProvider executes action\n    ↓\nResults returned through pipeline\n```\n\n**Specific Wiring**\n\n- `services/pipeline/src/index.ts` - Call connector service\n- `services/connector/src/index.ts` - Provider selection logic\n- `services/mcp-connector/src/index.ts` - MCP call execution\n\n---\n\n### Phase 2C: Govern ↔ Tenants Bridge\n\n**What Needs to Be Wired**\n\n```\nGovern checks if action is allowed\n    ↓\n[MISSING] Govern calls tenants service\n    ↓\nTenants service:\n    - Checks RBAC\n    - Validates permissions\n    - Checks tier limits\n    ↓\nApproval/rejection returned\n```\n\n**Specific Wiring**\n\n- `services/govern/src/index.ts` - Call tenants for RBAC\n- `services/tenants/src/rbac.ts` - Permission evaluation\n\n---\n\n## Data Layer: Signal Processing\n\n### Phase 3A: Signal Ingestion\n\n**What Needs to Be Wired**\n\n```\nExternal event happens (webhook, connector event, user action)\n    ↓\n[MISSING] webhook-ingress service receives event\n    ↓\n[MISSING] Event is stored in signals service\n    ↓\n[MISSING] Event is broadcast to all listeners\n    ↓\nServices react to signals\n```\n\n**Specific Wiring**\n\n- `services/webhook-ingress/src/index.ts` - Parse incoming events\n- `services/signals/src/index.ts` - Store and broadcast events\n- Service subscriptions to signal types\n\n---\n\n### Phase 3B: Signal ↔ Learning Loop\n\n**What Needs to Be Wired**\n\n```\nHITL execution completes\n    ↓\n[MISSING] Results are captured as signal\n    ↓\n[MISSING] Signal is stored in signals service\n    ↓\n[MISSING] Learning pipeline processes signal\n    ↓\nKnowledge base is updated\n    ↓\nMemory is updated with outcome\n    ↓\nAgent models are adjusted\n```\n\n**Specific Wiring**\n\n- `services/signals/src/index.ts` - Capture execution results\n- Learning feedback integration points\n\n---\n\n## Configuration & Discovery\n\n### Phase 4A: Service Discovery\n\n**What Needs to Be Done**\n\n```\nService A needs to call Service B\n    ↓\n[MISSING] Service A looks up Service B's URL\n    ↓\nService discovery mechanism needed:\n    - Environment variables for known services\n    - Dynamic discovery for optional services\n    - Fallback chains for resilience\n```\n\n**Implementation Options**\n\n1. **Environment-based** (simplest for Cloudflare)\n   - Each service.wrangler.toml includes URLs of services it calls\n   - Services env section has INTELLIGENCE_URL, PIPELINE_URL, etc.\n\n2. **Registry-based** (more flexible)\n   - Agent-registry service lists all services\n   - Services query registry on startup\n\n**Recommendation**: Start with environment-based, migrate to registry later\n\n---\n\n### Phase 4B: Inter-Service Authentication\n\n**What Needs to Be Done**\n\n```\nService A calls Service B\n    ↓\n[MISSING] Service A needs to authenticate\n    ↓\nService B validates authentication\n    ↓\nService B checks authorization\n    ↓\nIf valid, execute; if not, reject\n```\n\n**Implementation**\n\n- Create service-to-service JWT tokens\n- Each service has INTERNAL_JWT_SECRET\n- Services sign requests with their secret\n- Receiving service validates signature\n\n---\n\n## Testing & Validation\n\n### Phase 5A: Integration Test Wiring\n\n**What Needs to Be Done**\n\n```\nTest creates request\n    ↓\n[MISSING] Test calls gateway like real client\n    ↓\n[MISSING] Request flows through real service chain\n    ↓\n[MISSING] Test validates end-to-end response\n```\n\n**Current State**: 450+ tests written, mostly unit tests\n**Missing**: Integration tests calling actual services\n\n**Key Integration Tests to Add**\n\n1. Test complete HITL flow (capture → propose → approve → execute)\n2. Test capability discovery and execution\n3. Test context enrichment\n4. Test error handling across service boundaries\n5. Test signal processing\n6. Test learning feedback loops\n\n---\n\n## Deployment Pipeline\n\n### Phase 6A: CI/CD Setup\n\n**What Needs to Be Done**\n\n```\nPush to main branch\n    ↓\n[MISSING] GitHub Actions triggered\n    ↓\n[MISSING] Run test suite\n    ↓\n[MISSING] If tests pass, deploy to staging\n    ↓\n[MISSING] Run smoke tests on staging\n    ↓\n[MISSING] If staging passes, deploy to production\n    ↓\nServices are live\n```\n\n**Specific Needs**\n\n- GitHub Actions workflow file\n- Wrangler authentication tokens\n- Database migration scripts\n- Rollback procedures\n\n---\n\n## Priority Ordering (Recommended)\n\n### Week 1: Critical Path (Enables all features)\n\n1. **Phase 1A**: Gateway service dispatcher\n   - Effort: 2 days\n   - Impact: High (unblocks everything else)\n\n2. **Phase 1B**: Database connectivity\n   - Effort: 2 days\n   - Impact: High (needed for state)\n\n3. **Phase 1C**: HITL orchestrator integration\n   - Effort: 2 days\n   - Impact: High (core feature)\n\n### Week 2: Continuity & Context\n\n4. **Phase 1D**: Continuity context chains\n   - Effort: 2 days\n   - Impact: High (improves decision-making)\n\n5. **Phase 2A-2C**: Service-to-service bridges\n   - Effort: 3 days\n   - Impact: High (enables distributed execution)\n\n### Week 3: Data & Operations\n\n6. **Phase 3A-3B**: Signal processing\n   - Effort: 2 days\n   - Impact: Medium (enables learning loop)\n\n7. **Phase 4A-4B**: Service discovery & auth\n   - Effort: 2 days\n   - Impact: High (enables reliability)\n\n8. **Phase 5-6**: Testing & deployment\n   - Effort: 3 days\n   - Impact: Critical (enables go-live)\n\n---\n\n## Success Metrics\n\n- [ ] Single request routes through 5+ services\n- [ ] Database CRUD operations work end-to-end\n- [ ] HITL flow completes successfully\n- [ ] Service-to-service calls succeed\n- [ ] Context is enriched across requests\n- [ ] 100+ integration tests pass\n- [ ] Signals are ingested and processed\n- [ ] Learning loop captures results\n- [ ] Services can be deployed to Cloudflare\n- [ ] Monitoring shows healthy service health\n\n---\n\n## Risk Mitigation\n\n### Risk 1: Service Communication Breaks\n\n**Mitigation**: Implement circuit breakers and fallback chains\n\n- If Intelligence is down, use cached proposals\n- If Connector fails, retry with exponential backoff\n\n### Risk 2: Database Deadlocks\n\n**Mitigation**: Implement query timeouts and connection pooling\n\n- D1 max query timeout: 30 seconds\n- Connection pool size: 5-10\n\n### Risk 3: Cascading Failures\n\n**Mitigation**: Implement timeout and bulkhead patterns\n\n- Each service call times out after 10 seconds\n- Limit concurrent calls to dependent services\n\n### Risk 4: Data Inconsistency\n\n**Mitigation**: Implement event sourcing and audit trails\n\n- All changes captured in signals service\n- Replay capability for recovery\n\n---\n\n## Summary\n\n**Wiring is the bridge between \"code complete\" and \"go live.\"**\n\n- **Code**: 100% complete ✓\n- **Testing**: 450+ tests written, mostly unit ✓\n- **Wiring**: 0% complete ← YOU ARE HERE\n- **Deployment**: 0% complete\n- **Production**: Goal\n\n**Next step**: Start with Phase 1A (Gateway dispatcher) and work through the critical path. Each phase unblocks the next.\n\n**Estimated time to production**: 3 weeks of focused wiring work\n"}