{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://memabra.local/schemas/trajectory.schema.json", "title": "Trajectory", "description": "Replayable task-level trace for routing and learning in memabra.", "type": "object", "additionalProperties": false, "required": [ "trajectory_id", "task", "context_snapshot", "candidate_sets", "decisions", "events", "outcome", "reward" ], "properties": { "trajectory_id": {"type": "string", "minLength": 1}, "task": { "type": "object", "additionalProperties": false, "required": ["task_id", "input", "channel", "created_at"], "properties": { "task_id": {"type": "string", "minLength": 1}, "input": {"type": "string", "minLength": 1}, "channel": {"type": "string", "minLength": 1}, "created_at": {"type": "string", "format": "date-time"}, "user_id": {"type": ["string", "null"]} } }, "context_snapshot": { "type": "object", "additionalProperties": false, "required": ["conversation_summary", "environment_summary"], "properties": { "conversation_summary": {"type": "string"}, "environment_summary": {"type": "string"}, "recent_failures": { "type": "array", "items": {"type": "string"}, "default": [] } } }, "candidate_sets": { "type": "object", "additionalProperties": false, "required": ["memory", "skill", "tool"], "properties": { "memory": {"type": "array", "items": {"$ref": "candidate_object.schema.json"}}, "skill": {"type": "array", "items": {"$ref": "candidate_object.schema.json"}}, "tool": {"type": "array", "items": {"$ref": "candidate_object.schema.json"}} } }, "decisions": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["step", "decision_type", "selected_ids", "rationale"], "properties": { "step": {"type": "integer", "minimum": 1}, "decision_type": { "type": "string", "enum": ["direct_answer", "inject_memory", "load_skill", "call_tool", "clarify", "composite_action"] }, "selected_ids": { "type": "array", "items": {"type": "string"} }, "rejected_ids": { "type": "array", "items": {"type": "string"}, "default": [] }, "rationale": {"type": "string"}, "estimated_cost": {"type": ["number", "null" ]} } } }, "events": { "type": "array", "items": {"$ref": "event.schema.json"} }, "outcome": { "type": "object", "additionalProperties": false, "required": ["status", "steps", "latency_ms", "user_corrections"], "properties": { "status": {"type": "string", "enum": ["success", "partial_success", "failure"]}, "steps": {"type": "integer", "minimum": 0}, "latency_ms": {"type": "integer", "minimum": 0}, "user_corrections": {"type": "integer", "minimum": 0}, "tool_errors": {"type": "integer", "minimum": 0}, "notes": {"type": ["string", "null"]} } }, "reward": { "type": "object", "additionalProperties": false, "required": ["total", "components"], "properties": { "total": {"type": "number"}, "components": { "type": "object", "required": ["task_success", "retrieval_hit", "tool_error", "user_correction", "latency", "context_cost", "useful_reuse"], "properties": { "task_success": {"type": "number"}, "retrieval_hit": {"type": "number"}, "tool_error": {"type": "number"}, "user_correction": {"type": "number"}, "latency": {"type": "number"}, "context_cost": {"type": "number"}, "useful_reuse": {"type": "number"} } } } } } }