File size: 2,620 Bytes
e6978c4 ecf2001 1931f9e ecf2001 e6978c4 2a52e14 e6978c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # SPEC-EVENTS — session event registry & hash-chaining
Every session appends to a local, hash-chained, append-only JSONL log:
`.freestream/sessions/<session-id>/events.jsonl`. A session is therefore a
**verifiable artifact**: tamper with any line and `verify()` fails.
## Chain format
One JSON object per line:
```json
{"seq": 3, "ts": 1759600000.123, "type": "session.status",
"payload": {"status": "ready"},
"prev": "<64-hex sha256 of entry 2>", "hash": "<64-hex>"}
```
- `hash = sha256(canonical({"seq","ts","type","payload","prev"}))`
where canonical = `json.dumps(sort_keys=True, separators=(",",":"))`.
- First entry's `prev` is the 64-zero genesis hash.
- `EventLog(path).verify() -> (ok, first_bad_seq)`; appending to a broken
chain raises instead of extending a lie.
## Registry
Types are namespaced. The initial registry:
| Type | Emitted by | Payload |
|---|---|---|
| `session.requested` | CLI join | platform, driver, bot_name, voice, rung, meet_url |
| `session.created` | CLI join | session_id, driver |
| `session.status` | driver poll | status |
| `session.ready` | CLI join | session_id |
| `session.failed` | CLI join | status |
| `session.timeout` | CLI join | — |
| `driver.join_attempted` | driver | driver, platform |
| `persona.rung_change` | avatar backend | from, to, reason |
| `asr.partial` / `asr.final` | ASR loop | text, speaker, confidence |
| `agent.speak` | MCP session.speak / bot | text |
| `agent.action` | CharacterAgent | text — in-fiction physical actions, never spoken |
| `agent.tool` | toolbelt | tool, args, ok, output — every terminal/file call, audited |
| `asr.speculative` | speculative dispatch | text, seconds, audio_s — dispatched at ~300ms of silence |
| `agent.speculative_canceled` | speculative turn | reason: speech_resumed (before playout) |
| `turn.completed` | bot | total_s, asr_s, speculative, throttled_periods, throttled_ms |
| `tts.synthesized` | persona | text, chars, backend |
| `avatar.frame_clock` | avatar backend | fps, rung |
| `persona.posture` | bot render loop | mode — idle/thinking/working/speaking on change |
| `session.leave` | CLI leave | session_id |
Rules:
1. Additions to the registry append; never repurpose or delete a type.
2. Payloads contain no raw audio or image bytes — references only
(durations, paths, hashes of the bytes).
3. `asr.partial` entries are prunable: a compaction pass may drop them and
re-issue a `log.compacted` entry, but the chain never breaks.
4. Logs are the replay input: a session log + the persona assets is a
full deterministic replay of what the bot said and when. |