{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scriptgrain-com/json-schema/scriptgrain-com-novelty-response-schema.json",
  "title": "NoveltyResponse",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scriptgrain-com-openapi.json#/components/schemas/NoveltyResponse",
  "type": "object",
  "required": [
    "profile_id",
    "check_id",
    "verdict",
    "repeat_count",
    "builds_on_count",
    "closest",
    "established",
    "gaps",
    "angles",
    "corpus",
    "candidates",
    "repeat_policy"
  ],
  "properties": {
    "profile_id": {
      "$ref": "#/$defs/Uuid"
    },
    "check_id": {
      "oneOf": [
        {
          "$ref": "#/$defs/Uuid"
        },
        {
          "type": "null"
        }
      ],
      "description": "The logged check; null if logging failed."
    },
    "verdict": {
      "type": "string",
      "enum": [
        "new",
        "builds_on",
        "repeats"
      ]
    },
    "repeat_count": {
      "type": "integer",
      "description": "Prior pieces at 0.86 similarity or above."
    },
    "builds_on_count": {
      "type": "integer",
      "description": "Prior pieces from 0.78 up to 0.86."
    },
    "closest": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/NoveltyNearestPiece"
      },
      "description": "Up to six, most similar first."
    },
    "established": {
      "type": "array",
      "description": "Up to five prior ideas to build on.",
      "items": {
        "type": "object",
        "required": [
          "text",
          "quote",
          "item_id",
          "title"
        ],
        "properties": {
          "text": {
            "type": "string"
          },
          "quote": {
            "type": "string"
          },
          "item_id": {
            "$ref": "#/$defs/Uuid"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "gaps": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Topics in the brief the memory has not, or has barely, covered."
    },
    "angles": {
      "type": "array",
      "description": "Up to three grounded angles.",
      "items": {
        "type": "object",
        "required": [
          "angle",
          "builds_on",
          "fills"
        ],
        "properties": {
          "angle": {
            "type": "string"
          },
          "builds_on": {
            "type": "string"
          },
          "fills": {
            "type": "string"
          }
        }
      }
    },
    "corpus": {
      "type": "object",
      "required": [
        "items",
        "units"
      ],
      "properties": {
        "items": {
          "type": "integer"
        },
        "units": {
          "type": "integer"
        }
      }
    },
    "candidates": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The arguments a piece from this brief would likely make."
    },
    "repeat_policy": {
      "$ref": "#/$defs/RepeatPolicy"
    }
  },
  "$defs": {
    "NoveltyNearestPiece": {
      "type": "object",
      "required": [
        "item_id",
        "title",
        "kind",
        "published_at",
        "similarity",
        "unit",
        "quote"
      ],
      "properties": {
        "item_id": {
          "$ref": "#/$defs/Uuid"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "kind": {
          "type": "string"
        },
        "published_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "similarity": {
          "type": "number"
        },
        "unit": {
          "type": "string",
          "description": "The closest memory in that piece."
        },
        "quote": {
          "type": "string"
        }
      }
    },
    "RepeatPolicy": {
      "type": "string",
      "enum": [
        "avoid",
        "allow"
      ]
    },
    "Uuid": {
      "type": "string",
      "format": "uuid",
      "description": "A UUID. Path ids that are not UUID-shaped never match a route (404 `not_found`)."
    }
  }
}