{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://atlasodkryc.pl/badanie/result-schema.json",
  "title": "Atlas usability review v0.1 — assessment, not human test results",
  "type": "object",
  "additionalProperties": false,
  "required": ["protocol_id", "study_id", "run_id", "review_type", "model", "input", "evidence", "task_results", "dimensions", "issues", "patterns", "pairwise", "limitations", "blinding_leaks", "unverified_facts", "usage", "human_adjudication"],
  "properties": {
    "protocol_id": {"const": "atlas-usability-v0.1"},
    "study_id": {"type": "string", "minLength": 1},
    "run_id": {"type": "string", "minLength": 1},
    "review_type": {"enum": ["absolute", "pairwise"]},
    "model": {"type": "object", "additionalProperties": false, "required": ["provider", "exact_id", "effort", "parameters", "prompt_sha256", "run_at"], "properties": {"provider": {"type": "string"}, "exact_id": {"type": "string"}, "effort": {"type": ["string", "null"]}, "parameters": {"type": "object"}, "prompt_sha256": {"$ref": "#/$defs/hash"}, "run_at": {"type": "string", "format": "date-time"}}},
    "input": {"type": "object", "additionalProperties": false, "required": ["blind_ids", "package_sha256", "task_manifest_sha256", "order_id"], "properties": {"blind_ids": {"type": "array", "minItems": 1, "maxItems": 2, "uniqueItems": true, "items": {"type": "string"}}, "package_sha256": {"type": "array", "minItems": 1, "maxItems": 2, "items": {"$ref": "#/$defs/hash"}}, "task_manifest_sha256": {"$ref": "#/$defs/hash"}, "order_id": {"type": ["string", "null"]}}},
    "evidence": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["id", "kind", "uri", "sha256", "locator", "condition", "description"], "properties": {"id": {"type": "string", "minLength": 1}, "kind": {"enum": ["screenshot", "recording", "action_trace", "dom", "accessibility_tree", "technical_test", "verified_source"]}, "uri": {"type": "string", "minLength": 1}, "sha256": {"$ref": "#/$defs/hash"}, "locator": {"type": "string", "description": "Kadr/obszar, timestamp, numer kroku albo selektor i stan; nie ogólny link do strony."}, "condition": {"type": "string", "description": "Desktop/mobile/narrow/text200/keyboard i ID konfiguracji."}, "description": {"type": "string"}}}},
    "task_results": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["task_id", "blind_id", "condition", "actor", "outcome", "reason", "evidence_ids", "scope_exclusion_approval", "human_completion_seconds"], "properties": {"task_id": {"type": "string"}, "blind_id": {"type": "string"}, "condition": {"type": "string"}, "actor": {"enum": ["script", "agent", "human", "not_executed"]}, "outcome": {"enum": ["success", "partial", "failure", "not_assessable", "not_applicable"]}, "reason": {"type": "string", "minLength": 1}, "evidence_ids": {"$ref": "#/$defs/evidenceIds"}, "scope_exclusion_approval": {"type": ["string", "null"]}, "human_completion_seconds": {"type": ["number", "null"], "minimum": 0}}, "allOf": [{"if": {"properties": {"actor": {"enum": ["script", "agent", "not_executed"]}}}, "then": {"properties": {"human_completion_seconds": {"type": "null"}}}}, {"if": {"properties": {"outcome": {"const": "not_applicable"}}}, "then": {"properties": {"scope_exclusion_approval": {"type": "string", "minLength": 1}}}}, {"if": {"properties": {"outcome": {"enum": ["success", "partial", "failure"]}}}, "then": {"properties": {"evidence_ids": {"minItems": 1}, "actor": {"enum": ["script", "agent", "human"]}}}}]}},
    "dimensions": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["dimension", "blind_id", "score", "reason", "evidence_ids", "claim_type"], "properties": {"dimension": {"enum": ["orientation", "information_architecture", "interaction_feedback", "readability_and_resilience", "form_supports_task", "sources_and_limits"]}, "blind_id": {"type": "string"}, "score": {"type": ["integer", "null"], "minimum": 0, "maximum": 3}, "reason": {"type": "string", "minLength": 1}, "evidence_ids": {"$ref": "#/$defs/evidenceIds"}, "claim_type": {"enum": ["observed", "hypothesis", "not_assessable"]}}, "allOf": [{"if": {"properties": {"score": {"type": "integer"}}}, "then": {"properties": {"evidence_ids": {"minItems": 1}}}}]}},
    "issues": {"type": "array", "maxItems": 5, "items": {"type": "object", "additionalProperties": false, "required": ["id", "blind_id", "severity", "claim_type", "kind", "description", "steps", "expected", "observed", "task_ids", "evidence_ids", "requires_human_confirmation"], "properties": {"id": {"type": "string"}, "blind_id": {"type": "string"}, "severity": {"enum": ["critical", "major", "minor"]}, "claim_type": {"enum": ["observed", "hypothesis"]}, "kind": {"enum": ["interface", "content_gap", "factual_risk", "evidence_failure", "test_harness_failure"]}, "description": {"type": "string"}, "steps": {"type": "array", "items": {"type": "string"}}, "expected": {"type": "string"}, "observed": {"type": "string"}, "task_ids": {"type": "array", "items": {"type": "string"}}, "evidence_ids": {"allOf": [{"$ref": "#/$defs/evidenceIds"}, {"minItems": 1}]}, "requires_human_confirmation": {"const": true}}}},
    "patterns": {"type": "array", "maxItems": 2, "items": {"type": "object", "additionalProperties": false, "required": ["mechanism", "task_benefit", "limits", "evidence_ids"], "properties": {"mechanism": {"type": "string"}, "task_benefit": {"type": "string"}, "limits": {"type": "string"}, "evidence_ids": {"allOf": [{"$ref": "#/$defs/evidenceIds"}, {"minItems": 1}]}}}},
    "pairwise": {"oneOf": [{"type": "null"}, {"type": "object", "additionalProperties": false, "required": ["pair_id", "x_blind_id", "y_blind_id", "preference", "reason", "evidence_ids_x", "evidence_ids_y", "tradeoffs"], "properties": {"pair_id": {"type": "string"}, "x_blind_id": {"type": "string"}, "y_blind_id": {"type": "string"}, "preference": {"enum": ["X", "Y", "tie", "insufficient_evidence"]}, "reason": {"type": "string", "minLength": 1}, "evidence_ids_x": {"$ref": "#/$defs/evidenceIds"}, "evidence_ids_y": {"$ref": "#/$defs/evidenceIds"}, "tradeoffs": {"type": "array", "items": {"type": "string"}}}, "allOf": [{"if": {"properties": {"preference": {"enum": ["X", "Y", "tie"]}}}, "then": {"properties": {"evidence_ids_x": {"minItems": 1}, "evidence_ids_y": {"minItems": 1}}}}]}]},
    "limitations": {"type": "array", "items": {"type": "string"}},
    "blinding_leaks": {"type": "array", "items": {"type": "string"}},
    "unverified_facts": {"type": "array", "items": {"type": "string"}},
    "usage": {"type": "object", "additionalProperties": false, "required": ["input_tokens", "output_tokens", "image_units", "tool_calls", "cost_pln", "cost_basis"], "properties": {"input_tokens": {"type": ["integer", "null"], "minimum": 0}, "output_tokens": {"type": ["integer", "null"], "minimum": 0}, "image_units": {"type": ["number", "null"], "minimum": 0}, "tool_calls": {"type": ["integer", "null"], "minimum": 0}, "cost_pln": {"type": ["number", "null"], "minimum": 0}, "cost_basis": {"type": ["string", "null"]}}},
    "human_adjudication": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["finding_id", "reviewer", "date", "decision", "reason", "evidence_ids"], "properties": {"finding_id": {"type": "string"}, "reviewer": {"type": "string"}, "date": {"type": "string", "format": "date-time"}, "decision": {"enum": ["confirmed", "rejected", "unresolved"]}, "reason": {"type": "string"}, "evidence_ids": {"$ref": "#/$defs/evidenceIds"}}}}
  },
  "allOf": [
    {"if": {"properties": {"review_type": {"const": "absolute"}}}, "then": {"properties": {"pairwise": {"type": "null"}, "input": {"properties": {"blind_ids": {"maxItems": 1}, "package_sha256": {"maxItems": 1}, "order_id": {"type": "null"}}}, "task_results": {"minItems": 1}, "dimensions": {"minItems": 6}}}},
    {"if": {"properties": {"review_type": {"const": "pairwise"}}}, "then": {"properties": {"pairwise": {"type": "object"}, "input": {"properties": {"blind_ids": {"minItems": 2}, "package_sha256": {"minItems": 2}, "order_id": {"type": "string", "minLength": 1}}}}}}
  ],
  "$defs": {"hash": {"type": "string", "pattern": "^[a-f0-9]{64}$"}, "evidenceIds": {"type": "array", "uniqueItems": true, "items": {"type": "string", "minLength": 1}}},
  "$comment": "Validate JSON schema plus relational constraints in runner: unique evidence and finding IDs; all evidence references resolve; every task/condition and all six dimensions exactly once per blind ID; preference X/Y refers to exact input ordering; metadata/usage from runner, not invented by model; human_adjudication supplied only by verified human workflow. Authoritative hidden mapping to topic/version stored separately. This is an assessment schema, not execution software."
}
