{"slug":"architecture/THREE_PROFILE_EXECUTION_MATRIX","title":"Three-Profile Execution Matrix","section":"architecture","sectionLabel":"Architecture","status":"unclassified","type":"document","path":"architecture/THREE_PROFILE_EXECUTION_MATRIX.mdx","bytes":24420,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n**Date:** 2026-07-31\n**Status:** Canonical — every action, binding, projection, and execution mapped\n**Principle:** Think in terms of ACTIONS and EXECUTIONS that happen as product, platform, and agent results\n\n---\n\n## The Three Profiles\n\n| Profile              | Who              | Purpose              | Activation                             |\n| -------------------- | ---------------- | -------------------- | -------------------------------------- |\n| **Dev Internal**     | Engineering team | Build, test, iterate | `tenant_id = dev-local`                |\n| **Customer Zero**    | Founder (you)    | Run entire business  | `tenant_id = customer-zero`            |\n| **Product to Users** | External users   | Use the product      | `tenant_id = {tenant}` via marketplace |\n\n**Same codebase. Same services. Split by `tenant_id` + request origin + JWT audience.**\n\n---\n\n## PROFILE 1: Dev Internal\n\n### What Happens (Actions)\n\n| #   | Action                 | Who triggers                             | What executes                                          | Result                   |\n| --- | ---------------------- | ---------------------------------------- | ------------------------------------------------------ | ------------------------ |\n| 1   | **Start dev server**   | `pnpm dev`                               | Gateway starts on :8787, all services register         | Local environment live   |\n| 2   | **Seed tenant**        | Migration script                         | D1 gets `dev-local` tenant with all tables             | Canonical Spine has data |\n| 3   | **Connect dev tools**  | Manual connector setup                   | Connector service registers Notion, GitHub, etc.       | Infra tools connected    |\n| 4   | **Run projection**     | `GET /api/v1/workspace/projection/:dept` | Projection Engine assembles entities → SharedWorkbench | Frontend gets data       |\n| 5   | **Test AI projection** | Schema AI generates projections          | `ai_entity_projection` table gets populated            | AI fields appear in UI   |\n| 6   | **Test OODA loop**     | Click entity → Twin → Approve            | Twin proposes → Governance evaluates → Hermes executes | Full loop works          |\n| 7   | **Run tests**          | `pnpm test`                              | Vitest across all packages                             | 140+ tests pass          |\n| 8   | **Typecheck**          | `pnpm typecheck`                         | tsc across all packages                                | Zero type errors         |\n\n### Bindings\n\n| Binding              | Value                 | Purpose             |\n| -------------------- | --------------------- | ------------------- |\n| `DATABASE_URL`       | local D1              | Canonical Spine     |\n| `CANONICAL_SPINE_DB` | local D1              | AI projection table |\n| `AUTH_SECRET`        | dev-secret            | Authentication      |\n| `IW_API_URL`         | http://localhost:8787 | API endpoint        |\n\n### Projections\n\n| View                    | What renders                        | Data source                                |\n| ----------------------- | ----------------------------------- | ------------------------------------------ |\n| All 16 Founder sections | Tables, boards, timelines, canvases | Projection Engine → SharedWorkbench        |\n| Entity 360              | Record detail + AI panel            | Projection Engine + AI Projection Enricher |\n| Connector Tray          | Available tools                     | Integration Manager                        |\n\n### Executions\n\n| Execution             | Path                                                   | Result                        |\n| --------------------- | ------------------------------------------------------ | ----------------------------- |\n| CRUD on any entity    | UI → Gateway → Projection Engine → Core Spine          | Entity created/updated        |\n| Twin proposal         | Click → Active Context Bundle → Twin → Proposal        | Proposal appears in Approvals |\n| Governance evaluation | Proposal → Governance evaluator → Policy check         | Approved/rejected             |\n| Hermes execution      | Approved proposal → Hermes → Provider                  | Action executed               |\n| AI projection refresh | Schema AI → `ai_entity_projection` → Projection Engine | AI fields updated             |\n\n---\n\n## PROFILE 2: Customer Zero (Founder)\n\n### What Happens (Actions)\n\n| #   | Action                 | Who triggers                | What executes                                            | Result                          |\n| --- | ---------------------- | --------------------------- | -------------------------------------------------------- | ------------------------------- |\n| 1   | **Login**              | Founder opens workbench     | Auth → TenantGate → resolves `customer-zero`             | Workspace loaded                |\n| 2   | **View Home**          | Navigation                  | Projection Engine → all 16 entities → AI projections     | Attention Queue + Today Summary |\n| 3   | **View Revenue**       | Lens switch                 | Projection Engine → deals, accounts, pipeline            | Revenue views with AI risk      |\n| 4   | **Click entity**       | User clicks deal            | Active Context Bundle → Entity360 → Twin panel           | Full context loaded             |\n| 5   | **Edit entity**        | User edits deal             | Changed tuple → capability prepare → governance → Hermes | Deal updated                    |\n| 6   | **Approve proposal**   | User approves Twin's action | Proposal → Governance → Hermes → Provider                | Action executed                 |\n| 7   | **View Company Pulse** | Cross-domain view           | Projection Engine → all domains → AI synthesis           | Cross-domain signals            |\n| 8   | **View OKRs**          | Objectives view             | Projection Engine → objectives → AI progress risk        | OKR tracking                    |\n| 9   | **View Decision Log**  | Decisions view              | Projection Engine → decisions → AI outcome tracking      | Decision memory                 |\n| 10  | **Connect tool**       | Connector Tray              | Integration Manager → Discovery → Activation             | New tool connected              |\n| 11  | **View billing**       | Admin view                  | Billing service → usage, invoices                        | Billing dashboard               |\n\n### Bindings\n\n| Binding                 | Value                        | Purpose             |\n| ----------------------- | ---------------------------- | ------------------- |\n| `DATABASE_URL`          | production D1                | Canonical Spine     |\n| `CANONICAL_SPINE_DB`    | production D1                | AI projection table |\n| `AUTH_SECRET`           | production secret            | Authentication      |\n| `IW_API_URL`            | https://api.integratewise.ai | API endpoint        |\n| All 30 service bindings | Gateway wrangler.toml        | Service mesh        |\n\n### Projections (16 sections × 16 entities = 256 possible views)\n\n| Section                       | Entities                                            | AI Fields                                                 | OODA Stage            |\n| ----------------------------- | --------------------------------------------------- | --------------------------------------------------------- | --------------------- |\n| Home / Role Brief             | KPI, Signal, Task, Decision                         | Health scores, risk assessment, next action               | Orient                |\n| My Work                       | Task, Commitment, Approval                          | Blocker detection, effort estimation, risk                | Orient → Decide       |\n| Strategic Objective Portfolio | Strategic Objective, Initiative, KPI, Company Risk  | Progress risk, dependency analysis, forecast              | Orient → Decide → Act |\n| Entity 360                    | Primary entity + relationships + timeline           | Full AI panel: health, risk, predictions, recommendations | Orient                |\n| Pipeline / Queue              | Company Risk, Decision, Approval, Department Health | Risk assessment, alternatives, precedent                  | Orient → Decide → Act |\n| Timeline                      | Event, Conversation, Decision, Outcome              | Pattern recognition, similar events                       | Orient                |\n| Calendar                      | Meeting, Task, Milestone, Renewal                   | Scheduling optimization, conflict detection               | Orient                |\n| Communications                | Conversation, Message, Contact                      | Sentiment analysis, relationship mapping                  | Orient                |\n| Documents & Knowledge         | Document, Attachment, Knowledge, Evidence           | Content analysis, gap detection                           | Orient                |\n| Signals & Risks               | Signal, Risk, Metric, Exception                     | Anomaly detection, cascade risk                           | Orient → Decide       |\n| Approvals                     | Proposal, Approval, Evidence                        | Risk assessment, financial impact, alternatives           | Decide → Act          |\n| Planning Canvas               | Goal, Initiative, Task, Document, Decision          | Progress tracking, resource allocation                    | Orient → Decide       |\n| Reports & Metrics             | KPI, Metric, Forecast, Summary                      | Trend analysis, benchmark comparison                      | Orient                |\n| Automation & Playbooks        | Workflow, Playbook, Capability, Execution           | Bottleneck detection, optimization                        | Orient → Decide       |\n| Recent Work                   | Recently viewed / changed entities                  | Change detection, relevance scoring                       | Orient                |\n| Twin Detail                   | Active entity + evidence + memory + capabilities    | Full AI context assembly                                  | Orient → Decide → Act |\n\n### Executions\n\n| Execution                      | Path                                                          | Result                                     |\n| ------------------------------ | ------------------------------------------------------------- | ------------------------------------------ |\n| **Create Strategic Objective** | Form → Gateway → Projection Engine → Core Spine               | Objective created, AI projection generated |\n| **Update Deal Stage**          | Kanban drag → capability → governance → Hermes → CRM provider | Deal stage updated in CRM                  |\n| **Approve Twin's Action**      | Click Approve → Governance → Hermes → Provider                | Action executed, audit logged              |\n| **Connect Notion**             | Connector Tray → Integration Manager → OAuth → Activation     | Notion connected, entities synced          |\n| **Generate AI Projection**     | Schema AI → tenant context → `ai_entity_projection`           | AI fields populated                        |\n| **Refresh Company Pulse**      | Cross-domain query → all entities → AI synthesis              | Pulse updated with latest signals          |\n| **Track OKR Progress**         | OKR entity → AI progress calculation → forecast               | Progress risk detected                     |\n| **Log Decision**               | Decision entity → AI outcome tracking → memory promotion      | Decision logged with outcomes              |\n\n---\n\n## PROFILE 3: Product to Users (Marketplace)\n\n### Activation Flow\n\n| #   | Action                             | Who triggers                       | What executes                                               | Result                       |\n| --- | ---------------------------------- | ---------------------------------- | ----------------------------------------------------------- | ---------------------------- |\n| 1   | **User installs from marketplace** | Plugin/MCP marketplace             | MarketplaceInstallation state machine → `initiated`         | Installation started         |\n| 2   | **Host platform detected**         | Spine ADK                          | Host Discovery → discover connected tools                   | Tools discovered             |\n| 3   | **Cascade discovery**              | Spine ADK                          | For each host tool: explore capabilities → connect → import | All 50 tools discovered      |\n| 4   | **Connector Tray populated**       | Integration Manager                | Discovered tools → Connector Tray UI                        | User sees all tools          |\n| 5   | **User picks tool**                | User clicks tool in Connector Tray | Configuration Manager → tool config activated               | Tool configured              |\n| 6   | **Activation Manager validates**   | Activation Manager                 | Consent → binding → hydration → `active`                    | Tool activated               |\n| 7   | **Spine Tunnel established**       | Platform repo                      | Tunnel between Operational Spine ↔ Canonical Spine          | Data route established       |\n| 8   | **Entities flow**                  | Pipeline                           | Connector → Normalizer → Core Spine → Projection Engine     | Entities appear in workbench |\n| 9   | **AI projections generated**       | Schema AI                          | Tenant context → dynamic schema → projections               | AI fields populated          |\n| 10  | **User sees workbench**            | Frontend                           | Projection Engine → SharedWorkbench → UI                    | Full workbench live          |\n\n### Marketplace Activation Types\n\n| Type              | Flow                                                                                          | Example                              |\n| ----------------- | --------------------------------------------------------------------------------------------- | ------------------------------------ |\n| **Direct**        | User picks from Connector Tray → Config Manager → Activation Manager → Spine Tunnel           | User connects Notion directly        |\n| **Host-imported** | Host platform discovery → Spine ADK → Import into Spine Network → Config Manager → Activation | ChatGPT has 50 apps → all discovered |\n\n### Bindings (Channel Repos)\n\n| Binding                | Value                 | Purpose                                       |\n| ---------------------- | --------------------- | --------------------------------------------- |\n| `SPINE_TUNNEL_URL`     | Platform SDK endpoint | Only route to canonical                       |\n| `CANONICAL_SPINE_DB`   | ❌ NOT BOUND          | Channel repos never access canonical directly |\n| `OPERATIONAL_SPINE_DB` | Channel-specific D1   | Channel operational state                     |\n| `HOST_PLATFORM_CONFIG` | Plugin/MCP config     | Host platform connection                      |\n\n### Projections (Channel)\n\n| View                     | What renders                 | Data source                          |\n| ------------------------ | ---------------------------- | ------------------------------------ |\n| Connector Tray           | Available + discovered tools | Integration Manager via Spine Tunnel |\n| Activation State Machine | Onboarding progress          | Activation Manager via Spine Tunnel  |\n| Channel Workbench        | Entities from host platform  | Operational Spine + AI projections   |\n\n### Executions (Channel)\n\n| Execution             | Path                                                            | Result                         |\n| --------------------- | --------------------------------------------------------------- | ------------------------------ |\n| **Plugin activation** | Plugin marketplace → Plugin repo → Spine Tunnel → Canonical     | Plugin entities in canonical   |\n| **MCP activation**    | MCP marketplace → MCP repo → Spine Tunnel → Canonical           | MCP tools in canonical         |\n| **Host discovery**    | Spine ADK → host API → discover tools → import                  | Tools added to Connector Tray  |\n| **Tool activation**   | User picks → Config Manager → Activation Manager → Spine Tunnel | Tool data flows through tunnel |\n| **AI projection**     | Schema AI → tenant context → projection table                   | AI fields for channel entities |\n| **Memory promotion**  | Channel memory → Spine Tunnel → Canonical memory                | Institutional memory preserved |\n\n---\n\n## The Complete Flow (All Profiles)\n\n```\n┌─────────────────────────────────────────────────────────────────┐\n│ USER ACTION                                                      │\n│ \"I want to see my revenue pipeline\"                              │\n└──────────────────────┬──────────────────────────────────────────┘\n                       │\n┌──────────────────────▼──────────────────────────────────────────┐\n│ FRONTEND                                                         │\n│ WorkbenchApp → context lens \"Revenue\" → entity types [\"deal\"]    │\n│ Calls: platform.getEntities({ department: \"revenue\" })           │\n└──────────────────────┬──────────────────────────────────────────┘\n                       │\n┌──────────────────────▼──────────────────────────────────────────┐\n│ PLATFORM FACADE (lib/platform/index.ts)                         │\n│ SpinePlatform.getEntities() → fetches from Gateway               │\n└──────────────────────┬──────────────────────────────────────────┘\n                       │\n┌──────────────────────▼──────────────────────────────────────────┐\n│ GATEWAY (services/gateway/src/index.ts)                          │\n│ Route: /api/v1/workspace/projection/revenue                      │\n│ TenantGate: resolves tenant_id from JWT                         │\n│ Forwards to: Projection Engine                                   │\n└──────────────────────┬──────────────────────────────────────────┘\n                       │\n┌──────────────────────▼──────────────────────────────────────────┐\n│ PROJECTION ENGINE (packages/projection-engine/)                  │\n│                                                                  │\n│ 1. ASSEMBLE — Get deals from Core Spine (D1)                    │\n│ 2. RESOLVE — Build relationship graph                           │\n│ 2.5 AI PROJECTION — Fetch AI fields from ai_entity_projection   │\n│ 3. ENRICH — Knowledge, Signals, Capabilities (parallel)         │\n│ 4. READINESS — Department operational readiness                 │\n│ 5. ACTIONS — Derive available actions                           │\n│ 6. TIMELINE — Build entity timeline                             │\n│ 7. MEMORY — Assemble memory                                     │\n│ 8. TWIN CONTEXT — Compose Twin-facing projection                │\n│                                                                  │\n│ Output: SharedWorkbench {                                        │\n│   entities: Map<string, SpineEntity[]>,  ← canonical + AI       │\n│   relationships, signals, capabilities, governance,              │\n│   actions, twinContext, readiness, provenance                    │\n│ }                                                                │\n└──────────────────────┬──────────────────────────────────────────┘\n                       │\n┌──────────────────────▼──────────────────────────────────────────┐\n│ FRONTEND RENDERS                                                 │\n│                                                                  │\n│ EntityCollection (tables, boards, timelines)                     │\n│   → each entity has: canonical fields + ai fields               │\n│   → AI fields show: health_score, risk_assessment,              │\n│     next_best_action, predicted_outcome                         │\n│                                                                  │\n│ EntityDetail (360 view)                                          │\n│   → full entity + AI panel + timeline + evidence                │\n│                                                                  │\n│ Twin Panel (click-triggered)                                     │\n│   → AI summary, recommendations, alternatives                   │\n└─────────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## The Three Execution Paths\n\n### Path 1: Dev Internal → Customer Zero\n\n```\nDev builds → Dev tests → Dev seeds data → Founder logs in →\nFounder sees workbench → Founder edits → AI projections generated →\nFounder approves Twin's action → Action executed → Results visible\n```\n\n### Path 2: Customer Zero → Product to Users\n\n```\nFounder validates → Product ships → User installs from marketplace →\nHost platform detected → Cascade discovery → Tools imported →\nUser picks tool → Config Manager activates → Spine Tunnel routes →\nEntities flow → AI projections generated → Workbench live\n```\n\n### Path 3: Agent Execution\n\n```\nTwin proposes → Governance evaluates → Policy check →\nHermes coordinates → Provider executes → Outcome reconciled →\nSpine updated → AI projection refreshed → UI shows result\n```\n\n---\n\n## What Each Profile Produces\n\n| Profile              | Produces                                                              | Consumes                                        |\n| -------------------- | --------------------------------------------------------------------- | ----------------------------------------------- |\n| **Dev Internal**     | Working code, passing tests, type-safe packages                       | Dev tools, local D1, mock data                  |\n| **Customer Zero**    | Real business decisions, institutional memory, operational continuity | Real tools (Notion, GitHub, HubSpot), real data |\n| **Product to Users** | Marketplace installations, channel activations, user workbenches      | Host platform APIs, marketplace catalogs        |\n\n---\n\n## The Rule\n\nEvery action has a binding. Every binding has a projection. Every projection has an execution. Every execution has a result. Every result feeds back into the system.\n\n**No orphan actions. No dead bindings. No unused projections. No silent executions. No invisible results.**\n"}