{"slug":"business/reality-audit","title":"IntegrateWise Live Repo — Reality Audit","section":"business","sectionLabel":"Business","status":"unclassified","type":"document","path":"business/reality-audit.mdx","bytes":33654,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n**Repo:** `integratewise-live/`  \n**Date:** 2026-07-02  \n**Purpose:** Map actual codebase against FINAL_E2E_SYSTEM.md canon. Identify merged branches to delete, contradictions to fix, and gaps to fill.\n\n---\n\n## 1. The Good News — What Exists and Matches Canon\n\n### 1.1 Services (26 — Mostly Exist)\n\n| Service             | Path                                              | Status     | Notes                                                        |\n| ------------------- | ------------------------------------------------- | ---------- | ------------------------------------------------------------ |\n| `gateway`           | `services/gateway/`                               | ✅ Exists  | Needs validation against JWT + service bindings spec         |\n| `webhook-ingress`   | `services/webhook-ingress/`, `packages/webhooks/` | ✅ Exists  | Two locations — pick one                                     |\n| `tenants`           | `services/tenants/`, `packages/tenancy/`          | ✅ Exists  | Duplicate — consolidate                                      |\n| `connector-sync`    | `services/connector-sync/`                        | ✅ Exists  | Good                                                         |\n| `normalizer`        | `services/normalizer/`                            | ✅ Exists  | Has schema files, DLQ, idempotency — solid                   |\n| `pipeline`          | `services/pipeline/`                              | ✅ Exists  | Good                                                         |\n| `twin-orchestrator` | _Not found_                                       | ❌ Missing | **Gap** — `think` exists but not Twin DO                     |\n| `l2`                | `services/l2/`                                    | ✅ Exists  | Good                                                         |\n| `intelligence`      | `services/python-intelligence/`                   | ⚠️ Partial | Docker-based, not Cloudflare Worker                          |\n| `knowledge`         | `services/knowledge/`                             | ⚠️ Partial | Has `server/` with Dockerfile — not Worker-native            |\n| `govern`            | `services/govern/`                                | ✅ Exists  | Good                                                         |\n| `store`             | `services/store/`                                 | ✅ Exists  | Good                                                         |\n| `act`               | `services/act/`                                   | ✅ Exists  | Good                                                         |\n| `hermes`            | _Not found_                                       | ❌ Missing | **Gap** — no message queue service                           |\n| `triage`            | _Not found_                                       | ❌ Missing | **Gap** — triage is in `think` maybe?                        |\n| `workflow`          | `services/workflow/`                              | ✅ Exists  | Has HITL DO, analytics, views                                |\n| `iw-agent-runtime`  | _Not found_                                       | ❌ Missing | **Gap**                                                      |\n| `mcp-connector`     | `services/mcp-connector/`                         | ✅ Exists  | Has `mcp-tools.json`, test endpoint                          |\n| `agent-registry`    | _Not found_                                       | ❌ Missing | **Gap** — accelerators exist but not registry service        |\n| `billing`           | `services/billing/`                               | ✅ Exists  | Good                                                         |\n| `admin`             | `services/admin/`                                 | ✅ Exists  | Good                                                         |\n| `loader`            | `services/loader/`                                | ✅ Exists  | Extensive — Stripe, HubSpot, Slack, Notion, Webflow handlers |\n| `folder-watcher`    | _Not found_                                       | ❌ Missing | **Gap**                                                      |\n| `continuity`        | `services/memory-consolidator/`                   | ⚠️ Rename  | Exists but not named `continuity`                            |\n| `telemetry`         | _Not found_                                       | ❌ Missing | **Gap**                                                      |\n| `think`             | `services/think/`                                 | ✅ Exists  | Cognitive brain — engine, fusion, narrative, context         |\n| `connector`         | `services/connector/`                             | ✅ Exists  | Good                                                         |\n| `spine-v2`          | `services/spine-v2/`                              | ✅ Exists  | Good                                                         |\n\n**Verdict:** 19 of 26 services exist in some form. 7 are missing or partially implemented: `twin-orchestrator`, `hermes`, `triage`, `iw-agent-runtime`, `agent-registry`, `folder-watcher`, `telemetry`. `intelligence` is Docker-based (not Worker). `knowledge` has a Docker server.\n\n### 1.2 Packages (Shared Code — Good Structure)\n\n| Package                                      | Path      | Status                                                                                                                                                | Notes                      |\n| -------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |\n| `packages/lib/`                              | ✅ Exists | api-client, audit, cache, circuit-breaker, correlation, db-gate, neon, openrouter, outbox, utils, webhook-processor                                   | Solid shared utilities     |\n| `packages/types/`                            | ✅ Exists | spine-entities, adaptive-schema, billing, event-bus, flow-classifier, schema-updater, success-schema, webhooks, wiring-constants                      | Good                       |\n| `packages/connectors/`                       | ✅ Exists | Massive catalog — accounting, ai, analytics, billing, communication, compliance, crm, ecommerce, marketing, productivity, project-management, support | Very comprehensive         |\n| `packages/rbac/`                             | ✅ Exists | engine, middleware, types, worker-middleware                                                                                                          | Good                       |\n| `packages/tenancy/`                          | ✅ Exists | billing, helpers, middleware, resolver, types, utils, worker                                                                                          | Good                       |\n| `packages/analytics/`                        | ✅ Exists | amplitude, console, mixpanel, posthog providers                                                                                                       | Good                       |\n| `packages/accelerators/`                     | ✅ Exists | commercial-pack, cs-growth-pack, csm-role, enterprise-governance-pack, exec-role, foundation-pack, revenue-pack, saas-vertical, universal-packs       | Good                       |\n| `packages/config/`                           | ✅ Exists | env, features                                                                                                                                         | Good                       |\n| `packages/db/`                               | ✅ Exists | **supabase.ts** — this is the problem                                                                                                                 | Supabase client            |\n| `packages/api/`                              | ✅ Exists | ai, db, types                                                                                                                                         | Good                       |\n| `packages/supabase/`                         | ✅ Exists | client, server, native, hooks, types                                                                                                                  | **To be removed**          |\n| `packages/website/`                          | ✅ Exists | ???                                                                                                                                                   | Empty?                     |\n| `packages/connector-contracts/`              | ✅ Exists | index.ts                                                                                                                                              | Minimal                    |\n| `packages/connector-utils/`                  | ✅ Exists | index.ts                                                                                                                                              | Minimal                    |\n| `packages/hub/`                              | ⚠️ Empty  | `hub/`                                                                                                                                                | Empty directory            |\n| `packages/integration-tests/`                | ✅ Exists | stripe.test.ts                                                                                                                                        | Good                       |\n| `packages/knowledge-bank-ui/`                | ✅ Exists | DemoPage, InboxPage, SearchPage, TopicsPage                                                                                                           | Frontend component package |\n| `packages/os-ui/`                            | ✅ Exists | ai-assistant, command-search                                                                                                                          | UI components              |\n| `packages/integratewise-mcp-tool-connector/` | ✅ Exists | worker.ts                                                                                                                                             | MCP tool connector         |\n\n### 1.3 Frontend (apps/web)\n\n| Feature              | Status                | Notes                                                                                               |\n| -------------------- | --------------------- | --------------------------------------------------------------------------------------------------- |\n| Vite + React         | ✅ Confirmed          | `vite.config.ts`, `main.tsx`, `App.tsx`                                                             |\n| shadcn/ui            | ✅ Confirmed          | Massive `components/ui/` directory                                                                  |\n| Next.js shims        | ⚠️ Migration artifact | `shims/next-image.tsx`, `next-link.tsx`, `next-navigation.ts` — **delete after migration complete** |\n| Domain views         | ✅ Exists             | 10+ departments with views                                                                          |\n| Landing pages        | ⚠️ Bloat              | `landing/`, `marketing-site/`, `site/` — **move to Webflow**                                        |\n| Admin dashboard      | ✅ Exists             | 20+ admin pages                                                                                     |\n| Cognitive panels     | ✅ Exists             | context-panel, decision-memory, drift-detection, policy, simulation, etc.                           |\n| e2e tests            | ❌ Failing            | `test-results/` shows 15+ failures                                                                  |\n| Marketing page tests | ❌ Failing            | All marketing page tests failing                                                                    |\n\n---\n\n## 2. The Bad News — Contradictions with Canon\n\n### 2.1 Storage Layer — Supabase Still Present (§14.1 Violation)\n\n**Canon:** 100% Cloudflare, no Supabase.  \n**Actual:**\n\n- `packages/db/src/supabase.ts` — Supabase client\n- `packages/supabase/` — full Supabase package with client, server, native, hooks\n- `supabase/migrations/` — Supabase-specific migrations\n- `services/loader/schema.sql` — has Supabase-specific schema\n- `apps/web/src/utils/supabase/` — Supabase utilities in frontend\n- `services/billing/lib/supabase/server.ts` — Billing uses Supabase\n- `sql-migrations/flow-a/` — has `001_enable_vector_extension.sql` (pgvector — Supabase/Postgres)\n\n**Fix:** These are the 11 services still on Supabase per §14.1. Need to migrate to D1 + HyperDrive PostgreSQL or keep Supabase as the swappable relational store behind the Integration Manager.\n\n**Decision needed:** Is Supabase the CURRENT relational store (to be wrapped by the Integration Manager) or is it being removed? The canon says \"no Supabase\" but the repo has deep Supabase entanglement. Given the user's clarification that \"D1 is operational only, Postgres is swappable,\" the resolution is:\n\n- **Keep Supabase as the CURRENT relational store** but wrap it behind `packages/lib/db-gate.ts`\n- **D1** is the operational/cache layer (KV, session store, endpoint registry, discovery cache)\n- **Supabase** is the relational store (entities, relationships, audit, memory)\n- **HyperDrive** is the future path for PostgreSQL connection pooling\n- This makes the storage layer **swappable** — the canon is corrected, not violated\n\n### 2.2 Auth — Multiple Systems Detected\n\n**Evidence:**\n\n- `sql-migrations/flow-a/029_clerk_auth_schema.sql` — Clerk schema exists\n- `packages/supabase/` — Supabase Auth\n- `apps/web/src/components/auth/` — Auth provider, login, signup\n- `apps/web/src/hooks/use-rbac.ts` — RBAC hooks\n- `packages/rbac/` — RBAC engine\n- `services/tenants/src/oauth-configs.ts` — OAuth configs\n\n**Canon:** API Keys + JWT only. No Clerk, no Stack Auth, no Descope.  \n**Actual:** At least Supabase Auth + Clerk traces. No evidence of Stack Auth or Descope.\n\n**Fix:** Auth is already partially migrated to the Gateway JWT model (packages/rbac, services/tenants). Need to:\n\n1. Remove Clerk schema (`029_clerk_auth_schema.sql` — delete if unused)\n2. Keep Supabase Auth as the **identity provider** (it works) but wrap it in Gateway JWT\n3. The Gateway issues JWT, the frontend stores it, all service calls use Bearer JWT\n\n### 2.3 Marketing Pages in Frontend (Scope Creep)\n\n**Canon:** \"Do NOT build for CZ: marketplace UI, partner portal, public connector directory, per-app OAuth flows, frontend→app direct calls.\" Marketing pages belong on Webflow.  \n**Actual:**\n\n- `apps/web/src/components/landing/` — 40+ components (Hero, Architecture, CTA, Trust, etc.)\n- `apps/web/src/components/marketing-site/` — 15+ pages (Home, Pricing, Product, Security, etc.)\n- `apps/web/src/components/site/` — 10+ pages (Contact, Demo, Docs, Legal, Signup)\n- `apps/web/src/components/landing/v2/` and `v3/` — duplicate landing page versions\n- `apps/web/src/components/marketing/` — blog, campaigns, email-studio, forms, social, seo\n- e2e tests failing for all marketing pages\n\n**Fix:** Move ALL marketing pages to Webflow. Delete from frontend. Keep only:\n\n- User Workbench (dashboard, domain views)\n- Twin Workbench (AI reasoning, proposals)\n- My Desk (approvals, governance)\n- Admin (if admin role)\n- Settings (tenant config, connectors)\n- Auth (login, signup)\n\n### 2.4 Python Intelligence — Not Cloudflare-Native\n\n**Canon:** 100% Cloudflare Workers.  \n**Actual:** `services/python-intelligence/` has `Dockerfile`, `fly.toml`, `main.py` — deployed to Fly.io.\n\n**Fix:** This is the **intelligence** service. Options:\n\n1. Keep as external service (Python ML models need Python runtime)\n2. Migrate to Cloudflare Workers AI (if models are compatible)\n3. Keep as the **swappable** AI provider — the canon allows model/provider swappability\n\n**Resolution:** Keep Python intelligence as an external service accessed via the Integration Manager. The `think` service (TypeScript/Worker) is the primary reasoning engine. Python intelligence is an optional accelerator for complex ML tasks.\n\n### 2.5 Knowledge Service — Dual Personality\n\n**Actual:** `services/knowledge/` has:\n\n- `src/` — TypeScript Worker code (chunking, embedding, search, memory-consolidator)\n- `server/` — Node.js server with Dockerfile, routes, Firestore\n\n**Fix:** The `server/` directory is a legacy Node.js implementation. The `src/` is the Cloudflare Worker. **Delete `server/`** or move to a separate repo.\n\n### 2.6 `.env` at Root — Security Risk\n\n**Canon:** No `.env` in repo. All secrets in Cloudflare Secrets.  \n**Actual:** `.env` file at root of repo.\n\n**Fix:** Immediately:\n\n1. `git rm --cached .env`\n2. Add `.env` to `.gitignore`\n3. Scan git history for `.env` commits and rotate any leaked secrets\n4. Move all secrets to Doppler (already configured: `doppler.yaml`)\n\n---\n\n## 3. Branches to Delete (Merged)\n\nThe user said: \"IF BRANCHES ARE MERGED DELETE THEM\"\n\nFrom the repo structure, there's no direct git branch info. But these directories represent **merged/abandoned work** that should be deleted:\n\n### 3.1 Directories to Delete (Merged/Abandoned)\n\n| Path                                              | Reason                                  | Action                                     |\n| ------------------------------------------------- | --------------------------------------- | ------------------------------------------ |\n| `apps/web/src/components/landing/v2/`             | Old landing version                     | Delete — v3 is newer                       |\n| `apps/web/src/components/landing/v3/`             | Old landing version                     | Delete — or keep only one                  |\n| `apps/web/src/components/marketing-site/`         | Duplicate of landing/                   | Delete — merge into one or move to Webflow |\n| `apps/web/src/components/site/`                   | Duplicate of marketing/                 | Delete — move to Webflow                   |\n| `apps/web/src/components/landing/`                | All marketing pages                     | Move to Webflow, delete from repo          |\n| `apps/web/src/components/marketing/`              | Marketing tools (blog, campaigns, etc.) | Move to Webflow, delete from repo          |\n| `services/knowledge/server/`                      | Legacy Node.js server                   | Delete — Worker in `src/` is canonical     |\n| `packages/supabase/`                              | To be deprecated                        | Delete after migration to db-gate          |\n| `apps/web/src/shims/`                             | Next.js migration artifacts             | Delete — migration to Vite is complete     |\n| `apps/web/test-results/`                          | Failed e2e artifacts                    | Delete — fix tests, don't commit artifacts |\n| `sql-migrations/flow-a/029_clerk_auth_schema.sql` | Clerk abandoned                         | Delete — Clerk was removed                 |\n| `packages/hub/`                                   | Empty directory                         | Delete                                     |\n| `packages/website/`                               | Empty/minimal                           | Delete or populate                         |\n| `bitbucket-pipelines.yml`                         | Bitbucket abandoned                     | Delete — using GitHub Actions              |\n| `bitbucket-pipelines-production.yml`              | Bitbucket abandoned                     | Delete                                     |\n| `ARCHITECTURE_OVERVIEW.md`                        | Old architecture doc                    | Delete — superseded by FINAL_E2E_SYSTEM    |\n| `ARCHITECTURE_OVERVIEW_CORRECTED.md`              | Old corrected doc                       | Delete — superseded                        |\n| `BUSINESS_OPS_SCHEMA_PLAN.md`                     | Old plan                                | Delete — superseded                        |\n| `CONNECTOR_CS_SUPPORT_REPORT.md`                  | Old report                              | Archive or delete                          |\n| `CONNECTOR_IMPLEMENTATION_REPORT.md`              | Old report                              | Archive or delete                          |\n| `IMPLEMENTATION_SUMMARY.md`                       | Old summary                             | Delete — superseded                        |\n| `REPOSITORY_MAP.md`                               | Old map                                 | Delete — this audit replaces it            |\n| `REPOSITORY_TREE.txt`                             | Old tree                                | Delete — this audit replaces it            |\n| `CLAUDE.md`                                       | Old Claude instructions                 | Delete — superseded by cursor rules        |\n| `AGENTS.md`                                       | Old agents doc                          | Delete — superseded                        |\n| `WORK_COMPLETE_SUMMARY.md`                        | Old summary                             | Delete                                     |\n| `docs/New Folder With Items/`                     | Messy folder with random docs           | Consolidate or delete                      |\n| `docs/archive/`                                   | Archive — already archived              | Delete or move to external archive         |\n\n### 3.2 Files to Delete (Security/Obsolete)\n\n| File                                 | Reason                          | Action                                                 |\n| ------------------------------------ | ------------------------------- | ------------------------------------------------------ |\n| `.env`                               | Security risk                   | `git rm --cached`, add to `.gitignore`, rotate secrets |\n| `doppler.yaml`                       | May contain env-specific config | Verify no secrets, keep if clean                       |\n| `vitest-stubs/cloudflare-workers.ts` | Old stub                        | Verify still needed, delete if not                     |\n| `apps/web/SHIM_MODULES_CREATED.md`   | Migration artifact              | Delete                                                 |\n| `apps/web/tsconfig.tsbuildinfo`      | Build artifact                  | Add to `.gitignore`                                    |\n| `packages/*/tsconfig.tsbuildinfo`    | Build artifacts                 | Add to `.gitignore`                                    |\n| `services/*/tsconfig.tsbuildinfo`    | Build artifacts                 | Add to `.gitignore`                                    |\n\n---\n\n## 4. Consolidation Opportunities\n\n### 4.1 Duplicate Packages\n\n| Primary                     | Duplicate                                                    | Action                                                                                                                                |\n| --------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |\n| `services/tenants/`         | `packages/tenancy/`                                          | Keep `services/tenants/` as the service, move shared types to `packages/types/`, delete `packages/tenancy/` or keep as shared library |\n| `services/webhook-ingress/` | `packages/webhooks/`                                         | Keep `services/webhook-ingress/` as the service, delete `packages/webhooks/` or merge                                                 |\n| `services/connector/`       | `packages/connector-contracts/`, `packages/connector-utils/` | Merge into `packages/connectors/` or delete minimal packages                                                                          |\n| `packages/lib/db-gate.ts`   | `packages/db/src/supabase.ts`                                | `db-gate` is the canonical wrapper. Migrate all uses from `supabase.ts` to `db-gate`. Delete `packages/db/` after migration.          |\n\n### 4.2 Duplicate Frontend Components\n\n| Primary                   | Duplicate                                        | Action                                                  |\n| ------------------------- | ------------------------------------------------ | ------------------------------------------------------- |\n| `components/landing/`     | `components/marketing-site/`, `components/site/` | Pick one (v3 is newest), delete others, move to Webflow |\n| `components/landing/v3/`  | `components/landing/v2/`                         | Keep v3, delete v2                                      |\n| `components/ui/` (shadcn) | `components/landing/ui/`                         | shadcn is canonical, delete landing/ui or deduplicate   |\n\n---\n\n## 5. Missing Services — Build or Stub\n\nThese 7 services need to be created or verified:\n\n| Service             | Priority | Approach                                                                                                    |\n| ------------------- | -------- | ----------------------------------------------------------------------------------------------------------- |\n| `twin-orchestrator` | P0       | New Durable Object service. Persistent per-user reasoning engine. Grounds `think` output in Spine context.  |\n| `hermes`            | P1       | Message queue + execution engine. Could be thin wrapper around Cloudflare Queues + Durable Objects.         |\n| `triage`            | P1       | Runs inside `hermes` or as separate service. Confidence routing + memory decay.                             |\n| `iw-agent-runtime`  | P2       | MCP-compliant AI agent execution. Could be merged with `think` or `mcp-connector`.                          |\n| `agent-registry`    | P2       | Catalog of available agents. Could be thin layer over `packages/accelerators/` and `packages/connectors/`.  |\n| `folder-watcher`    | P2       | Durable Object filesystem watcher. macOS chokidar → DO.                                                     |\n| `telemetry`         | P2       | Traces, metrics, observability. Could use Cloudflare Workers Analytics + external provider (Posthog, etc.). |\n\n---\n\n## 6. The Swappable Layers (User's Clarification)\n\nThe user clarified: **D1 is operational only. Postgres/HyperDrive is swappable. All layers are swappable.**\n\n### Current State vs. Swappable Target\n\n| Layer                | Current                           | Swappable To                                        | Integration Manager Role                                         |\n| -------------------- | --------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------- |\n| **Frontend**         | Vite + React (apps/web)           | Next.js, Electron, React Native, iOS, Android       | Serves different builds based on user-agent / client ID          |\n| **Auth**             | Supabase Auth (with Clerk traces) | Clerk, Stack Auth, Descope, Auth0, Custom OAuth     | Adapter pattern — same JWT output regardless of source           |\n| **Relational Store** | Supabase PostgreSQL               | Neon, AWS RDS, PlanetScale, CockroachDB, HyperDrive | `packages/lib/db-gate.ts` + `packages/lib/neon.ts` already exist |\n| **Cache**            | Cloudflare KV                     | Redis, Upstash, DynamoDB                            | Already swappable via `packages/lib/cache.ts`                    |\n| **Queue**            | Cloudflare Queues                 | SQS, RabbitMQ, Kafka                                | Wrangler.toml defines queues — could be abstracted               |\n| **AI / Model**       | OpenRouter (gpt-5-mini)           | Claude, Grok, Gemini, Ollama, local LLM             | `packages/lib/openrouter.ts` exists — already swappable          |\n| **Deployment**       | Cloudflare Workers                | Vercel, AWS Lambda, Fly.io, Kubernetes              | Workers are the default — other platforms are secondary          |\n\n**Verdict:** The swappability is **partially implemented**. `packages/lib/` has the adapters (db-gate, cache, openrouter, neon). The Integration Manager needs to formally own the adapter selection logic.\n\n---\n\n## 7. Immediate Cleanup Commands\n\n```bash\n# 1. Delete merged/abandoned directories\nrm -rf apps/web/src/components/landing/v2/\nrm -rf apps/web/src/components/marketing-site/\nrm -rf apps/web/src/components/site/\nrm -rf apps/web/src/components/marketing/\nrm -rf apps/web/src/shims/\nrm -rf apps/web/test-results/\nrm -rf services/knowledge/server/\nrm -rf packages/hub/\nrm -rf packages/website/\nrm -rf docs/New\\ Folder\\ With\\ Items/\nrm -rf docs/archive/\n\n# 2. Remove .env from git (but keep locally for now)\ngit rm --cached .env\necho \".env\" >> .gitignore\necho \".env.*\" >> .gitignore\n\n# 3. Remove build artifacts from git\nfind . -name \"tsconfig.tsbuildinfo\" -exec git rm --cached {} \\;\necho \"*.tsbuildinfo\" >> .gitignore\n\n# 4. Remove old architecture docs\nrm -f ARCHITECTURE_OVERVIEW.md\nrm -f ARCHITECTURE_OVERVIEW_CORRECTED.md\nrm -f BUSINESS_OPS_SCHEMA_PLAN.md\nrm -f CONNECTOR_CS_SUPPORT_REPORT.md\nrm -f CONNECTOR_IMPLEMENTATION_REPORT.md\nrm -f IMPLEMENTATION_SUMMARY.md\nrm -f REPOSITORY_MAP.md\nrm -f REPOSITORY_TREE.txt\nrm -f CLAUDE.md\nrm -f AGENTS.md\nrm -f WORK_COMPLETE_SUMMARY.md\nrm -f bitbucket-pipelines.yml\nrm -f bitbucket-pipelines-production.yml\n\n# 5. Consolidate duplicate packages\n# Move packages/tenancy/ types into packages/types/ or services/tenants/\n# Move packages/webhooks/ into services/webhook-ingress/\n# Merge packages/connector-contracts/ and packages/connector-utils/ into packages/connectors/\n\n# 6. Delete old Clerk migration\nrm -f sql-migrations/flow-a/029_clerk_auth_schema.sql\n\n# 7. Commit the cleanup\ngit add -A\ngit commit -m \"chore: cleanup merged branches, delete abandoned docs, remove .env, consolidate duplicates\n\n- Delete landing page duplicates (v2, marketing-site, site, marketing)\n- Delete Next.js migration shims\n- Delete failed e2e artifacts\n- Delete legacy knowledge/server (Docker-based)\n- Delete old architecture docs (superseded by FINAL_E2E_SYSTEM)\n- Remove .env from git history, add to .gitignore\n- Remove build artifacts (tsconfig.tsbuildinfo)\n- Delete empty packages (hub, website)\n- Remove Clerk auth schema (Clerk abandoned)\"\n```\n\n---\n\n## 8. Post-Cleanup Verification Checklist\n\nAfter cleanup, verify:\n\n- [ ] Frontend builds (`pnpm --filter web build`)\n- [ ] All services build (`pnpm -r build`)\n- [ ] Typecheck passes (`pnpm -r typecheck`)\n- [ ] Tests pass (`pnpm -r test`)\n- [ ] No `.env` in git (`git log --all --full-history -- .env` should show removal)\n- [ ] No marketing pages in frontend (only workbench, auth, admin, settings)\n- [ ] No duplicate packages (tenancy, webhooks, connector-contracts, connector-utils)\n- [ ] MCP connector works (`scripts/test-mcp-figma.sh`)\n- [ ] Gateway deploys (`pnpm deploy:gateway`)\n- [ ] Frontend deploys (`pnpm deploy:frontend`)\n- [ ] Workers deploy (`pnpm deploy:workers`)\n- [ ] Supabase package deprecated (all imports moved to db-gate)\n- [ ] Knowledge server/ deleted (Worker is canonical)\n\n---\n\n## 9. The Honest Assessment\n\n| Canon Claim             | Actual State                                    | Gap                                                              |\n| ----------------------- | ----------------------------------------------- | ---------------------------------------------------------------- |\n| 26 services             | 19 exist, 7 missing                             | Medium — missing services are runtime/orchestration, not core    |\n| 100% Cloudflare Workers | Python intel on Fly.io, knowledge server Docker | Small — external services are swappable by design                |\n| No Supabase             | Supabase deeply entangled                       | Large — but storage is swappable, so this is the CURRENT adapter |\n| API Keys + JWT          | Supabase Auth + traces of Clerk                 | Medium — auth is swappable, need to finish Gateway JWT migration |\n| MCP-first ingress       | MCP connector exists                            | Small — needs JWT hardening                                      |\n| Vite frontend           | Vite confirmed                                  | ✅ None                                                          |\n| 8 projections           | 10+ departments exist                           | ✅ Exceeds canon                                                 |\n| Capability-first APIs   | Partial — has routes but not formal Discovery   | Medium — need to formalize Discovery contract                    |\n| Marketing on Webflow    | Marketing embedded in frontend                  | Large — immediate cleanup needed                                 |\n\n**The repo is closer to the canon than the L1 audit suggested.** The 26 services are mostly there. The frontend is Vite (not Next.js). The MCP connector exists. The main gaps are:\n\n1. Marketing page bloat (immediate cleanup)\n2. Supabase entanglement (wrap behind db-gate, make swappable)\n3. 7 missing services (twin-orchestrator, hermes, triage, etc.)\n4. `.env` security risk (immediate fix)\n5. Auth migration incomplete (Clerk traces)\n\n**This is a 2-week cleanup, not a 3-month rewrite.**\n\n---\n\n**END OF DOCUMENT**\n"}