{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://ultimate-pi.local/.pi/harness/specs/plan-task-clarification.schema.json",
	"title": "PlanTaskClarification",
	"description": "Upfront task contract before harness plan reconnaissance (Phase 0).",
	"type": "object",
	"additionalProperties": false,
	"required": [
		"schema_version",
		"status",
		"source_task",
		"clarified_task",
		"success_definition",
		"in_scope",
		"out_of_scope",
		"acceptance_checks_draft",
		"assumptions",
		"risk_level",
		"unresolved_questions",
		"clarification_rounds",
		"task_input_hash"
	],
	"properties": {
		"schema_version": { "type": "string", "const": "1.0.0" },
		"status": {
			"type": "string",
			"enum": ["draft", "needs_user", "needs_clarification", "ready"]
		},
		"source_task": { "type": "string", "minLength": 1 },
		"clarified_task": { "type": "string", "minLength": 1 },
		"success_definition": { "type": "string", "minLength": 1 },
		"in_scope": {
			"type": "array",
			"items": { "type": "string", "minLength": 1 }
		},
		"out_of_scope": {
			"type": "array",
			"items": { "type": "string", "minLength": 1 }
		},
		"acceptance_checks_draft": {
			"type": "array",
			"minItems": 1,
			"items": { "type": "string", "minLength": 1 }
		},
		"assumptions": {
			"type": "array",
			"items": { "type": "string" }
		},
		"risk_level": {
			"type": "string",
			"enum": ["low", "med", "high"]
		},
		"constraints": {
			"type": "object",
			"properties": {
				"hard": { "type": "array", "items": { "type": "string" } },
				"soft": { "type": "array", "items": { "type": "string" } }
			},
			"additionalProperties": true
		},
		"unresolved_questions": {
			"type": "array",
			"items": { "type": "string" }
		},
		"clarification_rounds": { "type": "integer", "minimum": 0 },
		"task_input_hash": { "type": "string", "minLength": 1 },
		"evidence_refs": {
			"type": "array",
			"items": { "type": "string" }
		},
		"grounding": {
			"type": "object",
			"properties": {
				"repo_mentions": {
					"type": "array",
					"items": { "type": "string" }
				},
				"urls": { "type": "array", "items": { "type": "string" } },
				"tools_used": {
					"type": "array",
					"items": { "type": "string" }
				},
				"summary": { "type": "string" }
			},
			"additionalProperties": true
		},
		"user_engagement": {
			"type": "object",
			"properties": {
				"source": { "type": "string", "minLength": 1 },
				"recorded_at": { "type": "string" }
			},
			"required": ["source"],
			"additionalProperties": false
		}
	}
}
