{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fleetai-com/json-schema/fleetai-com-counsel-desk-task-qastate-response-schema.json",
  "title": "CounselDeskTaskQAStateResponse",
  "description": "Non-mutating lifecycle read.\n\nEvery state is scoped to the task's current version AND the requested\nsection set (default: all three); a run or report for another section\nset is not this one.\n\n* ``in_progress`` -- a CounselDesk run is RUNNING. A run in flight\n  supersedes an older finalized report, so a restart is readable while\n  it runs.\n* ``completed``   -- no run in flight and a finalized CounselDesk report\n  exists; ``sections`` / ``summary`` / ``meta_issues`` carry the projection.\n* ``not_found``   -- neither. A tombstone (finalized=False) surfaces its\n  ``report_id`` and failure diagnostics here.\n\n``verdict`` is set only on ``completed``: ``fail`` when any requested\nsection holds an objective finding against a ``required`` criterion, else\n``pass``. Findings against ``recommended`` criteria, and legal-judgment\ncalls against any criterion, are reported in ``sections`` and never\nchange the verdict; ``judgment_call_count`` counts the latter.\n\nA ``pass`` is not an approval. It says no required criterion fired on the\nrequested sections, over the defects this review can see. CounselDesk's\nquality sign-off stays a human decision in the peer-QA queue; a surface\nrendering this field must not present it as one, and must not present it\nat all for sections the run did not review.\n\n``score`` answers the question the verdict cannot: how much fired, rather\nthan whether anything did. It carries its own derivation so a reader can\ncheck it. It is not a grade and not an approval either, and nothing on\nthis route gates on it.",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fleetai-com-openapi.yml#/components/schemas/CounselDeskTaskQAStateResponse",
  "properties": {
    "task_key": {
      "type": "string",
      "title": "Task Key"
    },
    "task_id": {
      "type": "string",
      "title": "Task Id"
    },
    "task_version_id": {
      "type": "string",
      "title": "Task Version Id"
    },
    "qa_policy_version": {
      "type": "integer",
      "title": "Qa Policy Version",
      "default": 1
    },
    "policy_outdated": {
      "type": "boolean",
      "title": "Policy Outdated",
      "default": false
    },
    "status": {
      "type": "string",
      "enum": [
        "not_found",
        "in_progress",
        "completed"
      ],
      "title": "Status"
    },
    "workflow_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Workflow Id"
    },
    "report_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Report Id"
    },
    "summary": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Summary"
    },
    "verdict": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "pass",
            "fail"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Verdict"
    },
    "score": {
      "anyOf": [
        {
          "$ref": "#/$defs/CounselDeskTaskQAScore-Output"
        },
        {
          "type": "null"
        }
      ]
    },
    "review_coverage": {
      "anyOf": [
        {
          "$ref": "#/$defs/CounselDeskTaskQAReviewCoverage"
        },
        {
          "type": "null"
        }
      ]
    },
    "preflight": {
      "anyOf": [
        {
          "$ref": "#/$defs/CounselDeskTaskQAPreflight"
        },
        {
          "type": "null"
        }
      ]
    },
    "failed_criteria": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Failed Criteria"
    },
    "judgment_call_count": {
      "type": "integer",
      "title": "Judgment Call Count",
      "default": 0
    },
    "sections": {
      "anyOf": [
        {
          "$ref": "#/$defs/CounselDeskTaskQASections-Output"
        },
        {
          "type": "null"
        }
      ]
    },
    "meta_issues": {
      "items": {
        "$ref": "#/$defs/CounselDeskTaskQAMetaIssue"
      },
      "type": "array",
      "title": "Meta Issues"
    },
    "failure_reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Failure Reason"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error"
    },
    "note": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Note"
    }
  },
  "type": "object",
  "required": [
    "task_key",
    "task_id",
    "task_version_id",
    "status"
  ],
  "$defs": {
    "CounselDeskTaskQACriterionAssessment": {
      "properties": {
        "criterion": {
          "type": "string",
          "title": "Criterion"
        },
        "section": {
          "type": "string",
          "enum": [
            "prompt",
            "rubric",
            "load_bearing_files"
          ],
          "title": "Section"
        },
        "status": {
          "type": "string",
          "enum": [
            "reviewed_no_defect",
            "defect_found",
            "not_assessed"
          ],
          "title": "Status"
        },
        "evidence": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Evidence"
        },
        "limitation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Limitation"
        },
        "ambiguity": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ambiguity"
        }
      },
      "type": "object",
      "required": [
        "criterion",
        "section",
        "status"
      ],
      "title": "CounselDeskTaskQACriterionAssessment"
    },
    "CounselDeskTaskQACriterionScore": {
      "properties": {
        "criterion": {
          "type": "string",
          "title": "Criterion"
        },
        "severity": {
          "type": "integer",
          "title": "Severity"
        },
        "occurrences": {
          "type": "integer",
          "title": "Occurrences"
        },
        "satisfied": {
          "type": "boolean",
          "title": "Satisfied"
        },
        "earned": {
          "type": "integer",
          "title": "Earned"
        },
        "testable": {
          "type": "boolean",
          "title": "Testable",
          "default": true
        }
      },
      "type": "object",
      "required": [
        "criterion",
        "severity",
        "occurrences",
        "satisfied",
        "earned"
      ],
      "title": "CounselDeskTaskQACriterionScore",
      "description": "One criterion's contribution, shown so the total can be re-derived.\n\n``satisfied`` is false when any objective finding cites this criterion;\nlegal-judgment calls are not counted at all. Repeat findings do not\ncompound: an atom-by-atom criterion like ``RUBRIC-R3`` fans out one\nfinding per atom, so counting them would score a long rubric worse than a\nshort one with the same defect. ``occurrences`` is reported\nbecause it tells an author how much work the fix is, not because it moves\nthe number."
    },
    "CounselDeskTaskQADimensionScore": {
      "properties": {
        "score": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Score"
        },
        "weight": {
          "type": "number",
          "title": "Weight"
        },
        "severity_earned": {
          "type": "integer",
          "title": "Severity Earned"
        },
        "severity_total": {
          "type": "integer",
          "title": "Severity Total"
        },
        "contribution": {
          "type": "number",
          "title": "Contribution"
        },
        "unattributed": {
          "type": "integer",
          "title": "Unattributed",
          "default": 0
        },
        "criteria": {
          "items": {
            "$ref": "#/$defs/CounselDeskTaskQACriterionScore"
          },
          "type": "array",
          "title": "Criteria"
        }
      },
      "type": "object",
      "required": [
        "weight",
        "severity_earned",
        "severity_total",
        "contribution"
      ],
      "title": "CounselDeskTaskQADimensionScore",
      "description": "One dimension's score, out of 100, and the arithmetic behind it.\n\n``score`` is ``severity_earned / severity_total * 100``, rounded to a\ntenth: the severity-weighted share of this dimension's criteria that no\nfinding contradicted. ``contribution`` is that rounded score times\n``weight``, rounded again, and the three contributions sum to the overall\nscore. Rounding at each step rather than only at the end costs up to 0.08\nagainst the exact weighted mean, and buys an overall score the caller can\nre-derive from the three numbers it was given."
    },
    "CounselDeskTaskQAFinding": {
      "properties": {
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Id"
        },
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Title"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description"
        },
        "priority": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Priority"
        },
        "suggested_fix": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Suggested Fix"
        },
        "evidence_quality": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Evidence Quality"
        },
        "issue_type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Issue Type"
        },
        "criterion": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Criterion"
        },
        "gate": {
          "type": "string",
          "enum": [
            "required",
            "recommended"
          ],
          "title": "Gate",
          "default": "required"
        },
        "basis": {
          "type": "string",
          "enum": [
            "objective",
            "legal_judgment"
          ],
          "title": "Basis",
          "default": "objective"
        },
        "writer_position": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Writer Position"
        },
        "alternative": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Alternative"
        },
        "affected_paths": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Affected Paths"
        }
      },
      "type": "object",
      "title": "CounselDeskTaskQAFinding"
    },
    "CounselDeskTaskQAMetaIssue": {
      "properties": {
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Type"
        },
        "severity": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Severity"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description"
        }
      },
      "type": "object",
      "title": "CounselDeskTaskQAMetaIssue",
      "description": "A platform or tooling fault the investigator hit (pack gap, unreadable\nfile, judge unavailable). The description is redacted of Fleet\ninfrastructure identifiers (hosts, addresses, URLs, ARNs) and truncated;\nthe full text stays server-side under ``report_id``, and Fleet is escalated\nto on every high-severity one."
    },
    "CounselDeskTaskQAPreflight": {
      "properties": {
        "verdict": {
          "type": "string",
          "enum": [
            "pass",
            "fail"
          ],
          "title": "Verdict"
        },
        "findings": {
          "items": {
            "$ref": "#/$defs/CounselDeskTaskQAFinding"
          },
          "type": "array",
          "title": "Findings"
        },
        "prompt_word_count": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Prompt Word Count"
        }
      },
      "type": "object",
      "required": [
        "verdict"
      ],
      "title": "CounselDeskTaskQAPreflight",
      "description": "The deterministic checks, decided without a model.\n\n``PROMPT-R2`` / ``PROMPT-R3`` / ``PROMPT-R4`` are computable from the task\nversion alone, so they are answered on every response -- including before\nany investigator run exists -- and the brief tells the run they are already\nsettled. ``verdict`` here covers only these checks; the response's\ntop-level ``verdict`` folds them together with the review."
    },
    "CounselDeskTaskQAReviewCoverage": {
      "properties": {
        "assessments": {
          "items": {
            "$ref": "#/$defs/CounselDeskTaskQACriterionAssessment"
          },
          "type": "array",
          "title": "Assessments"
        }
      },
      "type": "object",
      "required": [
        "assessments"
      ],
      "title": "CounselDeskTaskQAReviewCoverage",
      "description": "Reported semantic coverage, separate from score and verdict.\n\nA structured objective finding establishes a reported defect. All other\nassessed states require the explicit summary ledger and its evidence.\nMissing, inconsistent or malformed declarations remain not_assessed."
    },
    "CounselDeskTaskQAScore-Output": {
      "properties": {
        "score": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Score"
        },
        "unattributed": {
          "type": "integer",
          "title": "Unattributed",
          "default": 0
        },
        "prompt": {
          "$ref": "#/$defs/CounselDeskTaskQADimensionScore"
        },
        "rubric": {
          "$ref": "#/$defs/CounselDeskTaskQADimensionScore"
        },
        "load_bearing_files": {
          "$ref": "#/$defs/CounselDeskTaskQADimensionScore"
        }
      },
      "type": "object",
      "required": [
        "prompt",
        "rubric",
        "load_bearing_files"
      ],
      "title": "CounselDeskTaskQAScore",
      "description": "The weighted numeric score, with every step of its derivation.\n\nA defect density over the criteria this review can see, not a grade and\nnot an approval. A criterion nobody filed against scores full marks\nwhether it was genuinely satisfied or merely never looked at -- except\nwhere the version gave the review nothing to test it against at all,\nwhich is provable and leaves it out of the arithmetic. So a high score\nmeans \"few criteria were contradicted\", not \"this task is good\".\nCounselDesk's quality sign-off stays a human decision in the peer-QA\nqueue, exactly as it does for ``verdict``; do not hill-climb this number\nand do not gate on it.\n\nScoped to the requested dimensions: one the run did not review scores\nNone, carries weight 0.0, and the remaining weights renormalize."
    },
    "CounselDeskTaskQASection": {
      "properties": {
        "findings": {
          "items": {
            "$ref": "#/$defs/CounselDeskTaskQAFinding"
          },
          "type": "array",
          "title": "Findings"
        },
        "verdict": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "pass",
                "fail"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Verdict"
        },
        "failed_criteria": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Failed Criteria"
        }
      },
      "type": "object",
      "title": "CounselDeskTaskQASection"
    },
    "CounselDeskTaskQASections-Output": {
      "properties": {
        "prompt": {
          "$ref": "#/$defs/CounselDeskTaskQASection"
        },
        "rubric": {
          "$ref": "#/$defs/CounselDeskTaskQASection"
        },
        "load_bearing_files": {
          "$ref": "#/$defs/CounselDeskTaskQASection"
        }
      },
      "type": "object",
      "title": "CounselDeskTaskQASections"
    }
  }
}