{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "governance-event",
	"title": "Governance Event",
	"description": "One append-only governance decision event (issues/0155). Structured, queryable, chain-hashed. adjudicated events are user-only.",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "event", "decidedBy", "confirmedAt", "rationale", "prevHash", "hash"],
	"properties": {
		"id": {
			"type": "string",
			"pattern": "^GOV-[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{3}$",
			"description": "GOV-YYYY-MM-DD-NNN, stable and unique."
		},
		"event": {
			"type": "string",
			"enum": ["candidate_opened", "adjudicated", "amended"]
		},
		"candidateId": {
			"type": "string",
			"description": "The candidate this event concerns (CAND-...)."
		},
		"ruleId": {
			"type": "string",
			"description": "Rule identifier with optional @version pin."
		},
		"decision": {
			"type": "string",
			"enum": ["promote", "reject", "merge", "defer", "adopt", "amend"]
		},
		"decidedBy": {
			"type": "string",
			"enum": ["agent", "user"]
		},
		"rationale": {
			"type": "string",
			"minLength": 1
		},
		"evidenceRefs": {
			"type": "array",
			"items": { "type": "string" }
		},
		"confirmedAt": {
			"type": "string",
			"format": "date-time"
		},
		"prevHash": {
			"type": ["string", "null"],
			"description": "sha256 chain hash of the previous event, or null for the genesis event."
		},
		"hash": {
			"type": "string",
			"pattern": "^sha256:[0-9a-f]{64}$",
			"description": "sha256 of canonicalJson(event without hash) chained onto prevHash."
		}
	},
	"allOf": [
		{
			"if": { "properties": { "event": { "const": "adjudicated" } } },
			"then": {
				"required": ["candidateId", "ruleId", "decision"],
				"properties": { "decidedBy": { "const": "user" } }
			}
		}
	]
}
