> ## Documentation Index
> Fetch the complete documentation index at: https://docs.10et.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Event Bus

> MAP event coordination for agents and flows

The MAP (Multiplayer Agent Protocol) event bus enables loose coupling between agents, flows, and external systems. Events flow through the Context Hub.

## Publishing Events

```bash theme={null}
# Via CLI
tenet context-hub emit "eval:scored" \
  --data "agent=test-coverage,delta=0.0031,improved=true"

# Via API
curl -X POST http://localhost:4360/api/events \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"type":"eval:scored","data":{"agent":"test-coverage","delta":0.0031}}'
```

## Event Types

| Pattern                | When Fired                      | Used By                           |
| ---------------------- | ------------------------------- | --------------------------------- |
| `eval:scored`          | After agent eval completes      | Auto-merge flow, training capture |
| `kanban:pickup`        | PP picks up a backlog issue     | Training data capture             |
| `session:ended`        | Session closes                  | Tuple mining flow                 |
| `peter:daily-complete` | Nightly loop finishes           | Summary reporting                 |
| `telemetry:insight`    | Telemetry agent finds something | PP experiment trigger             |
| `scope:impact`         | Cross-service change detected   | Cascade fix flow                  |
| `friction:detected`    | User friction event             | Auto-create issue                 |
| `review:scored`        | AI review completes             | Block merge on blockers           |
| `subway:task`          | Task from Subway mesh peer      | Create GitHub issue               |

## Subscribing (Flows)

Flows subscribe to events via pattern matching in `.tenet/flows/self-driving.yaml`:

```yaml theme={null}
flows:
  - name: auto-merge-on-improvement
    trigger:
      pattern: "eval:scored"
      condition: 'data.improved == "true"'
    actions:
      - type: command
        command: "gh pr merge {{data.pr_number}} --merge"
```

## Querying Events

```bash theme={null}
# Recent events
curl "http://localhost:4360/api/events?limit=20" \
  -H "Authorization: Bearer $TOKEN"

# Filter by type
curl "http://localhost:4360/api/events?pattern=eval:*&limit=10" \
  -H "Authorization: Bearer $TOKEN"
```

## Event-Driven Architecture

Events enable the self-driving pipeline without tight coupling:

```
Agent finishes eval
  → emits eval:scored
  → auto-merge flow catches it
  → merges PR if improved
  → emits kanban:done
  → training capture flow logs tuple
```

No component knows about the others. They communicate through events.
