{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"title": "Context Page",
	"description": "A persisted unit of distilled project knowledge under .amber/context/pages/. Block-structured JSON where every block cites the sources it rests on. See ADR-0009.",
	"type": "object",
	"required": ["schemaVersion", "pageId", "title", "sources", "blocks"],
	"properties": {
		"schemaVersion": { "type": "string", "enum": ["1.0.0", "1.1.0", "1.2.0"] },
		"pageId": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" },
		"title": { "type": "string", "minLength": 1 },
		"scope": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
		"classification": {
			"description": "Page-level classification metadata owned by the page (context/runtime contract §3.1); absent means the read-side effective projection applies — never a stored write-back.",
			"enum": ["public", "internal", "confidential", "restricted", "secret"]
		},
		"purpose": {
			"description": "Non-empty string referencing the Loadout scope (route or feature id).",
			"type": "string",
			"minLength": 1
		},
		"ttl": {
			"description": "ISO-8601 duration; the load-build derives the effective hard expiry from the page's ingest/refresh instant.",
			"type": "string",
			"pattern": "^P(?=(\\d|T\\d))(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(T(?=(\\d))(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+(?:\\.\\d+)?)S)?)?$"
		},
		"relabelDecision": {
			"description": "Reference to the committed human Decision authorizing a classification downgrade of a restricted/secret source (ingest refuses a downgrade that cannot show one).",
			"type": "object",
			"additionalProperties": false,
			"required": ["identity", "revision"],
			"properties": {
				"identity": { "type": "string", "minLength": 1 },
				"revision": { "type": "integer", "minimum": 1 }
			}
		},
		"knowledgeKind": {
			"enum": [
				"invariant",
				"decision",
				"pattern",
				"failure",
				"rejected-approach",
				"external-constraint",
				"unspecified"
			]
		},
		"supersedes": {
			"type": "array",
			"uniqueItems": true,
			"items": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" }
		},
		"assurance": {
			"type": "object",
			"additionalProperties": false,
			"properties": {
				"confidence": { "enum": ["low", "medium", "high"] },
				"maturity": { "enum": ["provisional", "reviewed", "validated"] }
			}
		},
		"sources": {
			"type": "object",
			"minProperties": 1,
			"additionalProperties": {
				"type": "object",
				"required": ["kind", "ref", "rawHash", "mutable"],
				"properties": {
					"kind": { "type": "string" },
					"ref": { "type": "string", "minLength": 1 },
					"rawHash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
					"normHash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
					"mutable": { "type": "boolean" },
					"excerpt": { "type": "string" },
					"excerptHash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
				},
				"allOf": [
					{
						"description": "mutable sources carry normHash; immutable sources carry an excerpt snapshot (ADR-0009 D5/D5a)",
						"if": { "properties": { "mutable": { "const": true } } },
						"then": { "required": ["normHash"] },
						"else": { "required": ["excerpt", "excerptHash"] }
					}
				]
			}
		},
		"blocks": {
			"type": "array",
			"minItems": 1,
			"items": {
				"type": "object",
				"required": ["type", "sources", "text"],
				"properties": {
					"type": { "enum": ["prose", "unknown"] },
					"sources": { "type": "array", "minItems": 1, "items": { "type": "string" } },
					"text": { "type": "string", "minLength": 1 }
				}
			}
		},
		"amber_protocol_version": { "type": "string" },
		"artifact_sequence": { "type": "integer" },
		"created_at": { "type": "string", "format": "date-time" },
		"artifact_type": { "type": "string" }
	}
}
