{"slug":"platform/06-twin-runtime","title":"06 — Twin Runtime","section":"platform","sectionLabel":"Platform","status":"unclassified","type":"document","path":"platform/06-twin-runtime.mdx","bytes":2479,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n> **Extracted from:** IntegrateWise Platform Specification Suite\n> **Region:** first_pass\n> **Original line:** 835\n> **Lines:** 58 | **Chars:** 2,236\n> **Status:** Raw extraction — requires review and canonicalization\n\n06 — Twin Runtime\n6.1 Responsibilities\nDrive the OODA loop for the user-facing Twin.\nCompose context, prompt, persona grammar, evidence, tool calls, capability selections.\nCalibrate confidence and produce proposals.\n6.2 Flow\nCopyUser input / screen-state\n↓\nContext Builder (Continuity Bridge, persona, screen)\n↓\nMemory Retrieval (07; meant to L1–L7)\n↓\nEvidence Ranking (02; evd\\_ refs sorted by recency + relevance)\n↓\nPrompt Builder (Persona Grammar)\n↓\nLLM call (Cloudflare AI Gateway, plumbed provider)\n↓\nTool selection (resolve capability or read-only spineRead)\n↓\nConfidence calibration (cap.confidenceThreshold)\n↓\nProposal generation (cap.governancePolicy == propose)\n↓\nTwin response (Message Object: blocks, evidence, snapshots, actions)\n6.3 Persona Grammar (canonical names already in existing spec)\nMaya (Sales) — terse, action-oriented.\nSana (CS) — cautious, evidence-heavy.\nTomás (Engineering) — diagnostic.\n…(others inherited from existing spec).\nGrammar is configuration in tenant_spine_config.persona_grammar_ref.\n\n6.4 Activation gate (safety invariant)\nPre-existing “evaluateActivation” from existing spec preserved.\nAdditional checks: minimum memory depth (L7 has at least one approved item), governance posture set, Continuity Bridge non-empty.\n6.5 Inputs\nUser chat / surface action.\nScreen-state projection (04).\nContinuity Bridge context.\n6.6 Outputs\nMessage Object per existing spec.\nCapability invocations (05).\nMemory intakes (07 → L1).\n6.7 Events\nProduced: TwinResponded, TwinProposing, TwinContextBuilt, TwinMemoryIntake.\nConsumed: every Projection/Stale from 04, every Memory Approve/Reject from 07, every Governance Decision from 09.\n6.8 APIs\nPOST /twin/chat, POST /twin/propose, GET /twin/messages/{msg_id}.\n6.9 State transitions (per turn)\nreceived → building → proposing | executing → responded → archived.\n\n6.10 Failure handling\nLLM timeout → degrade to “Last Good Answer” projection; mark TwinResponded(stale=true).\nPersona Grammar missing → fallback to neutral; warn.\nMemory retrieval empty → operation continues with explicit “no prior context” chip.\n6.11 Extension points\nCustom persona grammar via twin.grammar package.\nCustom tool resolvers.\n"}