JSON Schemas¶
CRP defines 10 JSON Schema files for all protocol data structures. These schemas are used for validation, documentation, and OpenAPI specification.
Schema Inventory¶
| Schema | File | Purpose |
|---|---|---|
| Task Intent | task-intent.json |
Input to dispatch() |
| Quality Report | quality-report.json |
Return from dispatch() |
| Session Handle | session-handle.json |
Return from init() |
| Session Status | session-status.json |
Return from session_status() |
| Envelope Preview | envelope-preview.json |
Return from preview_envelope() |
| Stream Event | stream-event.json |
Events from dispatch_stream() |
| Cost Estimate | cost-estimate.json |
Return from estimate_session() |
| CRP Error | crp-error.json |
Error responses |
| Persisted State Header | persisted-state-header.json |
Cold storage metadata |
| OpenAPI | openapi.json |
Full sidecar API spec |
All schemas are in the schemas/ directory at the repository root.
Task Intent¶
Input to dispatch(). All fields are optional:
{
"description": "Compare React and Vue",
"system_prompt": "You are a senior frontend architect.",
"task_input": "Focus on performance, DX, and ecosystem.",
"expected_output_type": "markdown",
"max_windows": 5,
"max_output_tokens": 4096,
"metadata": {
"project": "framework-eval",
"priority": "high"
}
}
| Field | Type | Description |
|---|---|---|
description |
string | Human-readable task description |
system_prompt |
string | System prompt for the LLM |
task_input |
string | The actual task/question |
expected_output_type |
enum | text, json, markdown, code |
max_windows |
integer | Maximum continuation windows |
max_output_tokens |
integer | Max tokens per window |
metadata |
object | Arbitrary key-value pairs (max 50 keys) |
Quality Report¶
Return from dispatch():
{
"session_id": "abc-123",
"window_id": "win-1",
"output": "The complete generated text...",
"quality_tier": "A",
"facts_extracted": 42,
"security_flags": {
"injection_markers": [],
"unicode_normalization": true,
"control_chars_stripped": false,
"truncation_detected": false,
"integrity_violations": []
}
}
| Field | Type | Description |
|---|---|---|
session_id |
UUID | Session identifier |
window_id |
string | Window identifier |
output |
string | Unmodified LLM output (Axiom 9) |
quality_tier |
enum | S, A, B, C, D |
facts_extracted |
integer | Number of facts extracted |
security_flags |
object | Security check results |
Quality Tiers¶
| Tier | Meaning |
|---|---|
| S | Exceptional — fully grounded, no hallucinations |
| A | Strong — minor gaps |
| B | Acceptable — some parametric claims |
| C | Marginal — significant gaps |
| D | Poor — mostly ungrounded |
Session Handle¶
Return from init():
{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"protocol_version": "2.0.0",
"capabilities": ["dispatch", "ingest", "stream", "tools"],
"created_at": "2026-04-10T12:00:00Z",
"expires_at": "2026-04-10T14:00:00Z"
}
| Field | Type | Description |
|---|---|---|
session_id |
UUID | Unique session identifier |
protocol_version |
SemVer | CRP version |
capabilities |
array | RBAC-granted capabilities |
created_at |
ISO 8601 | Creation timestamp |
expires_at |
ISO 8601 | Expiration timestamp |
Session Status¶
Return from session_status():
{
"session_id": "abc-123",
"windows_completed": 9,
"total_input_tokens": 34521,
"total_output_tokens": 9836,
"facts_in_warm_state": 372,
"overhead_ratio": 0.061,
"remaining_budget": null
}
Envelope Preview¶
Return from preview_envelope():
Stream Event¶
Events from dispatch_stream():
| Event Type | Data | When |
|---|---|---|
token |
String | Each token arrives |
extraction |
Progress object | Background extraction |
continuation |
Window metadata | New window starts |
window_complete |
Window stats | Window finishes |
done |
QualityReport | All generation complete |
error |
Error details | Something went wrong |
Cost Estimate¶
Return from estimate_session():
{
"estimated_windows": 5,
"estimated_input_tokens": 15000,
"estimated_output_tokens": 10000,
"estimated_cost_usd": 0.025,
"confidence": "medium"
}
CRP Error¶
Error response format:
{
"code": 1001,
"message": "Token budget exhausted",
"details": "Session abc-123 exceeded maximum token budget"
}
Error Codes¶
| Code | Name | Description |
|---|---|---|
| 1001 | BudgetExhausted | Token budget exceeded |
| 1002 | RateLimit | Rate limit hit |
| 1003 | SessionExpired | Session timed out |
| 1004 | SessionLimit | Max sessions reached |
| 1005 | SessionClosed | Session already closed |
| 1010 | ValidationError | Invalid input |
| 1011 | SecurityInvariant | Security check failed |
| 1012 | SignatureInvalid | HMAC signature mismatch |
| 1013 | RBACDenied | Permission denied |
| 1020 | ProviderError | LLM provider error |
| 1021 | ProviderTimeout | LLM provider timeout |
| 1030 | StateCorrupted | Internal state corruption |
| 1031 | ChainVerificationFailed | Audit chain integrity failure |
Persisted State Header¶
Cold storage / export metadata:
{
"schema_version": "1.0",
"protocol_version": "2.0.0",
"created_at": "2026-04-10T12:00:00Z",
"checksum": "blake3:abc123..."
}
Uses BLAKE3 for integrity verification.
OpenAPI¶
The full OpenAPI 3.1.0 specification for the HTTP Sidecar
is available at schemas/openapi.json. Import it into:
- Postman — Import → File →
openapi.json - Swagger UI — Point to the JSON file
- Any OpenAPI client generator — Generate clients for any language