{"slug":"business/FEATURE_MAP","title":"IntegrateWise Feature Mapping Document: Journey, Flow, & Infrastructure","section":"business","sectionLabel":"Business","status":"unclassified","type":"document","path":"business/FEATURE_MAP.mdx","bytes":9646,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n**Canonical Reference:** [docs/architecture/CANONICAL_PLATFORM_ARCHITECTURE.md](docs/architecture/CANONICAL_PLATFORM_ARCHITECTURE.md)\n\n> This document is downstream of the Canonical Platform Architecture. When this document contradicts the canonical architecture, the canonical architecture wins.\n\nThis document maps every core feature of the IntegrateWise Continuity Bridge to its respective **User Journey step**, **System Data Flow**, and **Cloudflare/Replit infrastructure runtime**.\n\n---\n\n## 1. Core Feature Matrix Mapping\n\n| Feature                                 | User Journey Step                                                                     | System Data Flow                                                                                              | Cloudflare Infrastructure                                                                                                | Replit / Local Dev Simulation                                             |\n| --------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- |\n| **Multi-Tenant Ingress Authentication** | **Activation & Discovery**:<br>User inputs Gateway JWT to identify context workspace. | JWT Bearer verification → Tenant ID claim extraction → context routing → `x-tenant-id` header injection.      | • Hono Gateway Worker<br>• `SESSIONS_PROD` KV namespace<br>• JWKS signing cache                                          | Local Hono server (port 8786) with mock JWT signing key validation.       |\n| **Unified Capability Discovery**        | **Onboarding / Value**:<br>AI client asks \"What can I do for this tenant?\".           | Gateway reads `ENDPOINT_REGISTRY` KV → dynamically filters list based on plan tier.                           | • `ENDPOINT_REGISTRY` KV<br>• gateway worker                                                                             | Mock JSON capability registry loaded into memory via `discovery.ts`.      |\n| **8-Stage Webhook Normalization**       | **Value (60-sec setup)**:<br>External events sync into the Spine.                     | Ingress worker → Queue → Normalizer (NA0–NA5 stages) → D1 Spine writer.                                       | • `webhook-ingress` worker<br>• `CONNECTOR_SYNC_QUEUE` Queue<br>• `normalizer` worker<br>• `integratewise-spine-prod` D1 | Stdio raw payload normalization piping using mock Webhook emitter.        |\n| **Stateful Twin Orchestration**         | **Daily Active Workflow**:<br>Twin observes context timeline.                         | Event arrival → trigger scoring → Twin DO loads active window → proposal generation.                          | • `twin-orchestrator` Durable Object<br>• `integratewise-spine-cache` D1<br>• Workers AI / OpenRouter                    | Local memory store with SQLite mock representing the tenant DO instance.  |\n| **Governance Gates ( HITL / Auto )**    | **Exception Governance**:<br>User reviews / approves AI actions.                      | Twin proposal → confidence scoring → Auto-approve (≥0.85) OR Handoff to My Desk (0.60–0.84) → D1 audit write. | • `govern` worker<br>• `proposals` D1 table<br>• `governance_audit_log` D1 table                                         | D1 proposals migration file applied locally using wrangler D1 migrations. |\n| **Capability ADK Resolution**           | **Daily Active Workflow**:<br>Invoking capabilities dynamically.                      | Request → Integration Manager checks plan tier and connector status → routes execution path.                  | • `@integratewise/integration-manager` package<br>• `ENDPOINT_REGISTRY` KV                                               | Stdio capability resolver unit tests with mock ResolverContext.           |\n| **Memory Consolidation & Decay**        | **Memory Accumulation**:<br>Insights and decisions compound.                          | Action outcomes → vector indexing → semantic search → periodic consolidation / decay.                         | • `continuity` worker<br>• `integratewise-embeddings` Vectorize index<br>• `org_memory` D1 table                         | Mock cosine similarity search utility mimicking Vectorize.                |\n| **Inbound MCP SSE Gateway**             | **AI Assistant Ingress**:<br>Cursor/Claude connects to the Bridge.                    | SSE handshake → JWT verification → tool catalog loading → tools execution mapping.                            | • `mcp-server` worker<br>• `SESSIONS_PROD` KV namespace                                                                  | Local SSE connection server with cursor-mcp-connector verification.       |\n\n---\n\n## 2. Ingress-to-Writeback Loop Trace (System Flow)\n\n```mermaid\nsequenceDiagram\n    autonumber\n    participant App as External App (Slack/SFDC)\n    participant Ingress as webhook-ingress Worker\n    participant Norm as normalizer Worker\n    participant Spine as spine-prod D1\n    participant Twin as twin-orchestrator DO\n    participant Govern as govern Worker\n    participant Workbench as My Desk UI (Vite)\n    participant Act as act Worker\n\n    App->>Ingress: 1. Send Event Webhook (e.g. Slack Escalation)\n    Ingress->>Norm: 2. Enqueue Raw Payload\n    Note over Norm: Enforce NA0-NA5 stages:<br/>Erase source identity, format UUIDs\n    Norm->>Spine: 3. Write Normalized Entity/Signal\n    Spine->>Twin: 4. Wakeup DO & Trigger Scoring\n    Note over Twin: Reasoning engine detects:<br/>Slack Escalation + SFDC ARR drop\n    Twin->>Govern: 5. Submit Action Proposal (Confidence 0.76)\n    Note over Govern: Score 0.76: HITL Gate Required\n    Govern->>Spine: 6. Write to proposals table (status: pending_review)\n    Govern->>Workbench: 7. Push Signal to User \"My Desk\" (SSE)\n    User/Workbench->>Govern: 8. Approve Proposal\n    Govern->>Act: 9. Dispatch Execution Package\n    Act->>App: 10. Writeback payload to target API\n    Act->>Spine: 11. Log Success in governance_audit_log\n```\n\n---\n\n## 3. Infrastructure Details: Cloudflare vs. Replit / Local\n\n### A. Cloudflare Native Setup\n\n1.  **Hono Gateway (`apps/gateway`)**:\n    - Acts as the central reverse proxy.\n    - Strips inbound `x-tenant-id` to prevent spoofing, extracts it from signed Gateway JWTs, and injects it back before invoking downstream bindings.\n2.  **MCP Server (`apps/mcp-server`)**:\n    - SSE (Server-Sent Events) endpoint allowing Cursor, Claude, or Perplexity to connect via a single JWT.\n    - Exposes a read-only capability catalog, ensuring all writes route through the `govern` approval queue.\n3.  **D1 Storage (`integratewise-spine-prod` & `integratewise-spine-cache`)**:\n    - `integratewise-spine-prod`: Central, rebuildable operational cache containing active entities, bindings, and active queues.\n    - `integratewise-spine-cache`: Central session cache containing proposals, audit logs, and DO state metadata.\n4.  **Vectorize**:\n    - Indexes organizational memory (`integratewise-embeddings`) and indexed docs (`integratewise-knowledge`) using 1536 dimensions.\n\n### B. Replit / Local Dev Simulation\n\nWhen running in Replit or a local dev shell, the serverless cloud bindings are simulated via Wrangler:\n\n1.  **Miniflare / Wrangler Dev**:\n    - Downstream Workers are mounted as local service bindings.\n    - D1 databases are simulated via local SQLite databases (`.wrangler/state/v3/d1`).\n2.  **Mock KV Namespaces**:\n    - Local directory caches simulate `SESSIONS_PROD` and `ENDPOINT_REGISTRY` values.\n3.  **Local Stdio Bridge**:\n    - A local Node aggregator (`scripts/mcpflare-aggregator.mjs`) mimics the SSE gateway, allowing local testing inside IDEs (Cursor/Kiro).\n\n---\n\n## 4. Integration Manager Pluggability Routing\n\nThe Integration Manager controls swappability using dynamic resolvers:\n\n```\n                  ┌──────────────────────┐\n                  │  Capability Request  │\n                  └──────────┬───────────┘\n                             │\n              [1. CapabilityResolver.resolve()]\n                             │\n                             ▼\n               Plan Tier & Connector Checks\n                             │\n                             ▼\n             ┌───────────────────────────────┐\n             │   IntegrationManager Router   │\n             └───────────────┬───────────────┘\n                             │\n            ┌────────────────┼────────────────┐\n            ▼                ▼                ▼\n     [Auth Provider]   [Database Target]   [Deployment Target]\n      - Gateway JWT     - Local D1          - Cloudflare Workers\n      - Clerk           - Neon Postgres     - Vercel (Next.js)\n      - Descope         - Supabase DB       - AWS Lambda\n```\n\n- **System of Record vs. Cache**: Relational data resides in the PostgreSQL instance of choice (Neon/Supabase) and is accessed via HyperDrive. Cloudflare D1 acts strictly as the temporary operational edge cache.\n"}