{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"type": "object",
	"required": ["sessionId", "schemaVersion", "createdAt", "route", "goal", "status"],
	"properties": {
		"sessionId": { "type": "string", "format": "uuid" },
		"schemaVersion": { "type": "string", "const": "1.0.0-rc.1" },
		"createdAt": { "type": "string", "format": "date-time" },
		"updatedAt": { "type": "string", "format": "date-time" },
		"route": {
			"type": "object",
			"required": ["id", "version"],
			"properties": {
				"id": { "type": "string" },
				"version": { "type": "string" }
			}
		},
		"goal": { "type": "string", "minLength": 1 },
		"feature": { "type": "string" },
		"status": {
			"enum": ["created", "routed", "executing", "paused", "completed", "failed", "aborted"]
		},
		"currentStage": { "type": "string" },
		"completedStages": { "type": "array", "items": { "type": "string" } },
		"budget": {
			"type": "object",
			"properties": {
				"total": { "type": "integer", "minimum": 0 },
				"used": {
					"type": ["integer", "null"],
					"minimum": 0,
					"description": "Externally supplied token usage. Null or absent means untracked. Amber does not measure token consumption and also displays legacy zero values as untracked."
				}
			}
		},
		"worktree": { "type": "string" },
		"amber_protocol_version": { "type": "string" },
		"artifact_sequence": { "type": "integer" },
		"created_at": { "type": "string", "format": "date-time" },
		"artifact_type": { "type": "string" },
		"agentId": {
			"type": "string",
			"description": "Agent identity that owns this session (set via `amber session start --agent <id>` or the MCP _agent parameter). Enables ownership-aware concurrency: a session may be managed by the agent that created it."
		},
		"agentClaimedAt": {
			"type": "string",
			"format": "date-time",
			"description": "When the owning agent claimed the session."
		},
		"journeyId": {
			"type": "string",
			"description": "The deep-journey id selected by decideRouteJourney for this session's goal (e.g. amber-delivery). Persisted so the journey half of the routing decision is not lost."
		},
		"lease": {
			"type": "object",
			"description": "F062 session lease projection. `session run` and `session settle` require owner and lease proof; the raw token is never persisted, only its SHA-256 digest. Reacquisition is explicit and creates a new fence.",
			"required": ["ownerId", "tokenHash", "acquiredAt", "expiresAt", "ttlMs", "fence"],
			"additionalProperties": false,
			"properties": {
				"ownerId": { "type": "string", "minLength": 1 },
				"tokenHash": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
				"acquiredAt": { "type": "string", "format": "date-time" },
				"expiresAt": { "type": "string", "format": "date-time" },
				"ttlMs": { "type": "integer", "minimum": 1, "maximum": 300000 },
				"fence": { "type": "integer", "minimum": 0 }
			}
		},
		"execution_context": {
			"type": "object",
			"properties": {
				"engine": { "enum": ["claude-code", "codex", "cursor"] },
				"model": { "type": "string" },
				"reasoning_effort": { "enum": ["low", "high", "max"] },
				"pinned_at": { "type": "string", "format": "date-time" },
				"pinned_by": { "type": "string" }
			}
		},
		"context_scope": {
			"description": "Trusted-control context/runtime contract §4: the authorization-relevant context constraints frozen into scopeInputs.context_scope. Absent means no context-constraint check existed (R-CA-4) — never defaulted.",
			"type": "object",
			"additionalProperties": false,
			"required": ["constraints"],
			"properties": {
				"constraints": {
					"type": "object",
					"additionalProperties": false,
					"required": ["maxClassification", "purpose", "expiresAt", "accessBoundaries"],
					"properties": {
						"maxClassification": {
							"enum": ["public", "internal", "confidential", "restricted", "secret", null]
						},
						"purpose": { "anyOf": [{ "type": "null" }, { "type": "string", "minLength": 1 }] },
						"expiresAt": {
							"anyOf": [{ "type": "null" }, { "type": "string", "format": "date-time" }]
						},
						"accessBoundaries": {
							"type": "array",
							"uniqueItems": true,
							"items": { "type": "string", "minLength": 1 }
						}
					}
				}
			}
		}
	}
}
