{"slug":"architecture/EXECUTION_FABRIC_v2","title":"Execution Fabric","section":"architecture","sectionLabel":"Architecture","status":"unclassified","type":"document","path":"architecture/EXECUTION_FABRIC_v2.mdx","bytes":4634,"description":"How work gets done — the set of capabilities that actually perform actions in external systems","updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n\n**How It Gets Done.**\n\nThe Execution Fabric is the set of capabilities that actually perform work in external systems. It is the \"hands\" of SpineWorkspace — the layer that translates approved decisions into real-world actions.\n\n## Design Principles\n\n1. **Governed execution** — Nothing executes without a governance token\n2. **Observable** — Every action is traced and auditable\n3. **Reversible** — Actions can be rolled back or compensated\n4. **Resilient** — Retries, circuit breakers, graceful degradation\n5. **Cost-aware** — Execution costs are tracked and budgeted\n\n---\n\n## Execution Components\n\n| Component | Purpose |\n|-----------|---------|\n| **APIs & Services** | Direct API calls to external systems |\n| **MCP / Tools** | Model Context Protocol tool invocations |\n| **Workflows** | Multi-step process execution |\n| **Hermes** | Execution service for complex actions |\n| **Functions / Workers** | Serverless compute execution |\n| **External Integrations** | Third-party service calls |\n\n---\n\n## Execution Flow\n\n```\nApproved Action → Execution Token → Routing → Adapter → External System → Receipt → Reconciliation\n```\n\n1. **Approved Action** — An action approved by governance\n2. **Execution Token** — Unique token for this execution\n3. **Routing** — Select the right execution path\n4. **Adapter** — Translate to target system format\n5. **External System** — Execute in the target system\n6. **Receipt** — Capture execution result\n7. **Reconciliation** — Verify outcome, feed to Spine\n\n---\n\n## Execution Token\n\nEvery execution requires a unique token:\n\n```typescript\ninterface ExecutionToken {\n  id: string;\n  tenantId: string;\n  workItemRef: string;\n  action: ActionDef;\n  approvedBy: ActorRef;\n  approvedAt: string;\n  expiresAt: string;\n  constraints: Constraint[];\n  budget: CostBudget;\n}\n```\n\n### Token Rules\n\n- Tokens are single-use\n- Tokens expire after a configurable TTL\n- Tokens are scoped to a specific action\n- Tokens cannot be reused or transferred\n- Invalid or expired tokens reject execution\n\n---\n\n## MCP / Tools\n\nThe Model Context Protocol provides a standard interface for tool invocation:\n\n| Tool Category | Examples |\n|---------------|----------|\n| **Data Operations** | Read, write, query, transform |\n| **Communication** | Send message, schedule meeting |\n| **File Operations** | Create, update, share document |\n| **Workflow** | Start process, advance stage |\n| **Integration** | Call external API, sync data |\n\n### MCP Tool Contract\n\n```typescript\ninterface MCPTool {\n  id: string;\n  name: string;\n  description: string;\n  inputSchema: JSONSchema;\n  outputSchema: JSONSchema;\n  permissions: Permission[];\n  cost: CostEstimate;\n  \n  execute(input: unknown, context: ExecutionContext): Promise<ToolResult>;\n}\n```\n\n---\n\n## Hermes (Execution Service)\n\nHermes is the primary execution service for complex actions:\n\n| Capability | Description |\n|------------|-------------|\n| **Multi-step execution** | Execute chains of dependent actions |\n| **Parallel execution** | Execute independent actions simultaneously |\n| **Compensation** | Rollback or compensate on failure |\n| **Timeout handling** | Graceful handling of slow operations |\n| **Idempotency** | Safe retry of failed executions |\n\n---\n\n## Functions / Workers\n\nServerless compute for custom execution logic:\n\n| Use Case | Implementation |\n|----------|---------------|\n| **Custom transforms** | Data transformation functions |\n| **Validation** | Custom validation rules |\n| **Enrichment** | Data enrichment from multiple sources |\n| **Aggregation** | Combine data from multiple systems |\n| **Notification** | Custom notification logic |\n\n---\n\n## Execution Monitoring\n\n| Metric | Description |\n|--------|-------------|\n| **Execution count** | Total executions per time period |\n| **Success rate** | Percentage of successful executions |\n| **Average latency** | Time from token to receipt |\n| **Error rate** | Percentage of failed executions |\n| **Cost per execution** | Token and compute costs |\n| **External system health** | Health of connected systems |\n\n---\n\n## Governance\n\n| Rule | Description |\n|------|-------------|\n| **Token required** | No execution without a valid token |\n| **Scope limited** | Token scoped to specific action |\n| **Time limited** | Token expires after TTL |\n| **Budget limited** | Execution cost tracked and limited |\n| **Audit logged** | Every execution is audited |\n| **Rollback capable** | Actions can be compensated |\n"}