npm package: @surasak-tm24/governance-runtime
Description: OpenClaw Governance Runtime - IGF-compliant AI agent governance with execution engine, federated learning, and policy enforcement
Author: OpenClaw Team
Latest version: 1.0.1

# @openclaw/governance-runtime

IGF-compliant AI agent governance runtime with execution engine, federated learning, and policy enforcement.

## Features

- ✅ **Governance Runtime** - IGF v9.3 compliant governance
- ✅ **Execution Engine** - 14-state execution lifecycle
- ✅ **Federated Learning** - Privacy-preserving distributed learning
- ✅ **Conflict Resolution** - Auto-resolve model conflicts
- ✅ **Human Approval** - Multi-level review workflow
- ✅ **Policy Enforcement** - Runtime policy checks
- ✅ **Risk Scoring** - Real-time risk assessment

## Installation

```bash
npm install @openclaw/governance-runtime
```

## Quick Start

```javascript
import { createServer } from '@openclaw/governance-runtime';

// Start the governance API server
const { runtime, executionEngine } = createServer({
  port: 4010,
  mode: 'normal'
});

// Check health
console.log(runtime.getHealthStatus());
```

## Usage

### Governance Runtime

```javascript
import { GovernanceRuntime } from '@openclaw/governance-runtime';

const runtime = new GovernanceRuntime({
  mode: 'normal',
  riskThreshold: 0.7
});

await runtime.initialize();

// Check status
const status = runtime.getHealthStatus();
console.log(status);
```

### Execution Engine

```javascript
import { ExecutionEngine } from '@openclaw/governance-runtime';

const engine = new ExecutionEngine();

// Create execution
const execution = await engine.createExecution({
  type: 'skill',
  skill: 'ai-agent',
  payload: { action: 'process' },
  priority: 5
});

// Start execution
await engine.startExecution(execution.id);

// Complete execution
await engine.completeExecution(execution.id, { result: 'success' });
```

### Federated Learning

```javascript
import { FederatedLearningEngine } from '@openclaw/governance-runtime';

const fl = new FederatedLearningEngine({
  minClients: 3,
  rounds: 10
});

// Register clients
fl.registerClient('client-1', [1, 2, 3]);
fl.registerClient('client-2', [4, 5, 6]);
fl.registerClient('client-3', [7, 8, 9]);

// Train
await fl.train();

// Get global model
const model = fl.getGlobalModel();
```

### Human Approval

```javascript
import { HumanApprovalSystem } from '@openclaw/governance-runtime';

const approval = new HumanApprovalSystem({
  requiredApprovals: 2
});

// Create request
const request = approval.createRequest({
  type: 'model_deployment',
  title: 'Deploy new model',
  description: 'Deploy federated model to production',
  requester: 'system'
});

// Approve
approval.approve(request.id, 'admin-1', 'LGTM');
approval.approve(request.id, 'admin-2', 'Approved');
```

## API Reference

### GovernanceRuntime

| Method | Description |
|--------|-------------|
| `initialize()` | Initialize runtime |
| `getHealthStatus()` | Get health status |
| `validateExecution()` | Validate execution |
| `registerSkill()` | Register a skill |

### ExecutionEngine

| Method | Description |
|--------|-------------|
| `createExecution()` | Create execution |
| `startExecution()` | Start execution |
| `completeExecution()` | Complete execution |
| `failExecution()` | Fail execution |
| `getExecution()` | Get execution |
| `getAllExecutions()` | Get all executions |

### FederatedLearningEngine

| Method | Description |
|--------|-------------|
| `registerClient()` | Register client |
| `trainLocalModel()` | Train local model |
| `aggregateModels()` | Aggregate models |
| `runRound()` | Run one round |
| `train()` | Full training |

## License

MIT