|
| 1 | +# TUI-Gateway Contract Matrix (Single-Version Baseline) |
| 2 | + |
| 3 | +This document freezes the contract that TUI consumes from gateway. |
| 4 | +It is intentionally single-version and fail-fast by design. |
| 5 | + |
| 6 | +## Scope |
| 7 | + |
| 8 | +- Transport contract: JSON-RPC 2.0 (`internal/gateway/protocol`) |
| 9 | +- Runtime contract: gateway DTOs (`internal/gateway/contracts.go`) |
| 10 | +- Event payload version source of truth: `internal/runtime/controlplane/envelope.go` |
| 11 | + |
| 12 | +## RPC Methods Used By TUI |
| 13 | + |
| 14 | +| Method | Params Type | Result Payload | Notes | |
| 15 | +| --- | --- | --- | --- | |
| 16 | +| `gateway.authenticate` | `protocol.AuthenticateParams` | frame ack | Must succeed before runtime actions | |
| 17 | +| `gateway.bindStream` | `protocol.BindStreamParams` | frame ack | Binds session/run event stream | |
| 18 | +| `gateway.run` | `protocol.RunParams` | frame ack with `session_id`/`run_id` | Async acceptance only | |
| 19 | +| `gateway.compact` | `protocol.CompactParams` | `gateway.CompactResult` | Manual compact | |
| 20 | +| `gateway.executeSystemTool` | `protocol.ExecuteSystemToolParams` | `tools.ToolResult` | Tool execution passthrough | |
| 21 | +| `gateway.resolvePermission` | `protocol.ResolvePermissionParams` | frame ack | Permission decision submit | |
| 22 | +| `gateway.cancel` | `protocol.CancelParams` | frame ack | Cancels run by run/session binding | |
| 23 | +| `gateway.listSessions` | none | `[]gateway.SessionSummary` | Session list | |
| 24 | +| `gateway.loadSession` | `protocol.LoadSessionParams` | `gateway.Session` | Full session snapshot | |
| 25 | +| `gateway.activateSessionSkill` | `protocol.ActivateSessionSkillParams` | frame ack | Activate skill in session | |
| 26 | +| `gateway.deactivateSessionSkill` | `protocol.DeactivateSessionSkillParams` | frame ack | Deactivate skill in session | |
| 27 | +| `gateway.listSessionSkills` | `protocol.ListSessionSkillsParams` | `[]gateway.SessionSkillState` | Active skill states | |
| 28 | +| `gateway.listAvailableSkills` | `protocol.ListAvailableSkillsParams` | `[]gateway.AvailableSkillState` | Available skill catalog | |
| 29 | + |
| 30 | +## Runtime Event Contract |
| 31 | + |
| 32 | +- Notification method: `gateway.event` |
| 33 | +- TUI only accepts a runtime envelope payload with these required keys: |
| 34 | + - `runtime_event_type` (string) |
| 35 | + - `turn` (number) |
| 36 | + - `phase` (string) |
| 37 | + - `timestamp` (RFC3339 or RFC3339Nano) |
| 38 | + - `payload_version` (number) |
| 39 | + - `payload` (event-specific object/string) |
| 40 | +- `payload_version` must equal `controlplane.PayloadVersion`. |
| 41 | +- Version mismatch is treated as a hard incompatibility and must fail fast. |
| 42 | + |
| 43 | +## Error Contract |
| 44 | + |
| 45 | +TUI consumes standard JSON-RPC errors and gateway extended error codes from |
| 46 | +`protocol.JSONRPCError.Data.GatewayCode`. |
| 47 | + |
| 48 | +Primary gateway codes used for UI mapping: |
| 49 | + |
| 50 | +- `invalid_frame` |
| 51 | +- `invalid_action` |
| 52 | +- `invalid_multimodal_payload` |
| 53 | +- `missing_required_field` |
| 54 | +- `unsupported_action` |
| 55 | +- `internal_error` |
| 56 | +- `timeout` |
| 57 | +- `unsafe_path` |
| 58 | +- `unauthorized` |
| 59 | +- `access_denied` |
| 60 | +- `resource_not_found` |
| 61 | + |
| 62 | +## Non-Goals |
| 63 | + |
| 64 | +- No multi-version payload decoding. |
| 65 | +- No alias method fallback. |
| 66 | +- No legacy field fallback in event payload. |
0 commit comments