Unclassified

Spine → Twin Boundary Architecture

What Spine owns, what Twin owns, what Entity 360 bridges, and what Govern gates.


Current Surface-Binding Doctrine

  • Operational Workbench = the primary work surface; left sidebar nav; Twin sidebar pops out when needed.
  • Twin Workbench = full AI ecosystem surface (skills, knowledge, agents, prompts, conversational library).
  • Governance is embedded at every layer — not a separate workbench.
  • OpenWebUI is not the customer-facing product shell.
  • Twin / OpenWebUI runtime surfaces use the canonical Forest + Paper system language.
  • Midnight Executive is investor-deck / fundraising language only.

Use older L1/L2 / workspace / knowledge-UI language in this file through that boundary if any historical phrasing remains.


Boundary Overview

┌───────────────────────────────────────────────────────────────────────────────────┐
│                              IntegrateWise Platform                               │
│                                                                                   │
│  ┌──────────┐     ┌──────────────┐     ┌────────────────┐    ┌──────────┐    ┌───┐│
│  │  SPINE   │────▶│  ENTITY 360  │────▶│ MorningContext │───▶│   TWIN   │────▶│GOV││
│  │ (Write)  │     │  (Assembly)  │     │  (Edge Builder)│    │ (Reason) │    │   ││
│  └──────────┘     └──────────────┘     └────────────────┘    └──────────┘    └───┘│
│       ▲                                                              │         │  │
│       │                                 NEVER                        │         │  │
│       └─────────────────────────────────── ✗ ────────────────────────┘         │  │
│                                                                                │  │
│  Twin NEVER writes to Spine. Twin reasons strictly over edge MorningContext.   │  │
└───────────────────────────────────────────────────────────────────────────────────┘

What Spine Owns

Spine is the source of truth for all entity data. It owns writes, schema, and routing.

ResponsibilityImplementationDetails
Entity storageSpine DB tables (entities_account, entities_contact, etc.)Partitioned by workspace_id, RLS enforced
Schema definitionPostgres migrationsEntity types, field types, constraints, computed columns
Schema routingRouter WorkerDetermines which table an entity writes to based on type
Source attributionsource_attributions tableEvery field tagged with source, confidence, sync timestamp
Identity linksidentity_links tableMaps entity_id to external IDs across systems
Conflict resolution rulesconflict_rules table (JSONB)Per-field rules: latest-wins, highest-confidence, manual
Write validationCHECK constraints + triggersConfidence range, required fields, type validation
Event emissionentity_changed events on Cloudflare QueueDownstream consumers (Assembler, Twin) subscribe

Spine's Contract

  • Spine accepts writes ONLY from the Writer Worker (end of Flow A pipeline).
  • Spine emits entity_changed events for every write.
  • Spine never calls external APIs — it is a pure persistence layer.
  • Spine schema is version-controlled and deployed via migrations.

What Twin Owns

Twin is the reasoning layer. It evaluates triggers and produces insights.

ResponsibilityImplementationDetails
Trigger definitionstrigger_definitions table14 built-in types + custom triggers
Trigger evaluationTwin Worker (Intelligence)Evaluates conditions against Entity 360 snapshots
Insight generationtwin_insights tableSeverity, evidence, recommended action, entity_id
Insight routingNotification WorkerRoutes insights to correct view (CSM Hub, Intelligence)
Trigger suppressionDedup logic in Twin WorkerSame trigger + entity within 24h = suppressed
Evaluation historytrigger_evaluations tableAudit trail of every evaluation (fired or not)

Twin's Contract

  • Twin reads ONLY from the Edge-Local Morning Context Retrieval Layer (MorningContext / MorningContextBuilder) — never from raw database/Supabase tables, ensuring 100% sandboxed reasoning.
  • Twin writes ONLY to twin_insights and trigger_evaluations — never to Spine entity tables.
  • Twin does not mutate entity data. It observes and reasons.
  • Twin's insights are advisory — they recommend actions (Playbooks) but do not execute them.

Why Twin Never Writes to Spine

RiskDescriptionMitigation
Feedback loopsInsight changes entity → triggers new evaluation → new insight → infinite loopWrite isolation eliminates the possibility
Data corruptionReasoning error writes bad data to source of truthTwin has no write access to Spine
Audit confusionHard to distinguish human-sourced data from machine-generatedClear boundary: Spine = external data, Twin = internal reasoning
Trust erosionUsers can't trust entity data if AI modified itEntity data is always from connected sources, never from Twin

What Entity 360 Bridges

Entity 360 is the assembly layer — a read-only API that merges Spine data into a unified view.

ResponsibilityImplementationDetails
Multi-source assemblyAssembler WorkerReads all source data for an entity, merges into one response
Field conflict resolutionTrust rules engineApplies conflict_rules to determine winning value per field
Health score computationWeighted formulaUsage (40%) + Support (25%) + Engagement (20%) + Billing (15%)
Relationship mappingGraph query on identity_linksSurfaces related entities (contacts at account, etc.)
Timeline assemblyChronological mergeEvents from all sources sorted by timestamp
Edge cachingCloudflare KV60-second TTL, invalidated on entity_changed event
Progressive hydrationTiered responseProfile (fast) → Timeline (async) → Insights (async)

Entity 360's Contract

  • Entity 360 reads from Spine tables — it never writes to them.
  • Entity 360 is the ONLY read surface for Twin — Twin never queries Spine directly.
  • Entity 360 responses include trust metadata (sources, confidence, lastSync).
  • Entity 360 is stateless — it assembles on demand (with edge caching).

What Govern Gates

Govern is the approval layer for high-impact actions.

ActionGate TypeApproversTimeout
Entity merge (identity resolution)Single approvalWorkspace admin or CSM72 hours
Entity deleteDouble approvalAdmin + second admin48 hours
Bulk field overrideSingle approvalWorkspace admin24 hours
Connector disconnectSingle approvalWorkspace adminImmediate
Schema migration (custom fields)Admin approvalPlatform admin7 days
Export (PII-containing data)Compliance approvalCompliance officer48 hours

Govern's Contract

  • Govern does not own data — it gates access to Spine write operations.
  • Govern creates approval_requests with status: pending → approved/rejected.
  • Approved actions execute via the Writer Worker (same path as pipeline writes).
  • Rejected actions are logged but never executed.
  • All Govern decisions are audited in govern_audit_log.

Data Flow Summary by Boundary

FlowPathWrites To
Flow A (Ingest)Connector → Loader → Normalizer → Resolver → Router → WriterSpine ✅
Flow B (Assemble)Spine → Assembler → Entity 360 cacheKV cache only (read-only from Spine)
Flow C (Reason)Entity 360 → Twin → Insightstwin_insights ✅ (never Spine)
Flow D (Gate)User action → Govern → Approval → WriterSpine ✅ (only after approval)

Boundary Violations to Watch For

ViolationDetectionSeverity
Twin writes to Spine tableRLS policy + audit logCritical — architectural breach
Entity 360 mutates dataAssembler Worker has read-only DB roleCritical — should be impossible
Writer bypasses Govern for gated actionGovern middleware check on WriterHigh — compliance risk
Direct Spine read from UI (bypassing Entity 360)API gateway routing rulesMedium — consistency risk
Twin reads raw Spine tables (bypassing Entity 360)Network policy + code reviewMedium — coupling risk