{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kovatools-com/json-schema/kovatools-com-journal-entry-schema.json",
  "title": "JournalEntry",
  "x-generated": "2026-11-14",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kovatools-com-openapi.yml#/components/schemas/JournalEntry",
  "type": "object",
  "properties": {
    "uuid": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "decision",
        "read"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "published",
        "dismissed",
        "retracted"
      ]
    },
    "title": {
      "type": "string"
    },
    "content": {
      "type": "string"
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "published_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "valid_until": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "outdated": {
      "type": "boolean"
    },
    "previous_entry_uuid": {
      "type": [
        "string",
        "null"
      ]
    },
    "follow_up_uuids": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "image_uuid": {
      "type": [
        "string",
        "null"
      ]
    },
    "image_description": {
      "type": [
        "string",
        "null"
      ]
    },
    "revision": {
      "type": "integer",
      "minimum": 0
    },
    "served_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "feedback": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "relevance": {
          "type": "string",
          "enum": [
            "relevant",
            "not_relevant"
          ]
        },
        "explanation": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "relevance",
        "explanation"
      ]
    },
    "own": {
      "type": "boolean",
      "description": "True when the entry belongs to the current user."
    },
    "shared": {
      "type": "boolean",
      "description": "True when other journal readers can currently see this entry: a publisher shared it at publication, it is still published, and its author is still a publisher."
    },
    "strategy_uuid": {
      "type": [
        "string",
        "null"
      ],
      "description": "Author only."
    },
    "evidence": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Private source evidence, returned only to the author."
    },
    "revisions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/JournalRevision"
      },
      "description": "Present on show responses."
    },
    "editorial": {
      "type": [
        "object",
        "null"
      ],
      "description": "Author-only editorial judgment and optional question for the agent conversation.",
      "properties": {
        "outcome": {
          "type": "string",
          "enum": [
            "skip",
            "draft",
            "needs_context"
          ]
        },
        "editorial_reason": {
          "type": "string"
        },
        "question": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "outcome",
        "editorial_reason",
        "question"
      ],
      "additionalProperties": false
    },
    "refinement": {
      "type": [
        "object",
        "null"
      ],
      "description": "Author-only latest saved explanation. New updates record it synchronously with status completed. The field name and historical async states remain for compatibility; new updates do not require polling.",
      "properties": {
        "request_key": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "queued",
            "running",
            "completed",
            "failed",
            "superseded"
          ]
        },
        "error_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "author_context": {
          "type": "string"
        },
        "submitted_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "request_key",
        "status",
        "error_code",
        "author_context",
        "submitted_at"
      ],
      "additionalProperties": false
    },
    "contextual_numbers_allowed": {
      "type": "boolean",
      "description": "Author-only; contextual portfolio numbers are permitted only for publisher decisions on an explicitly enabled strategy."
    },
    "image": {
      "type": [
        "object",
        "null"
      ],
      "description": "Only present on show with include_image=true; null when no chart is attached. Base64 data is private and access-checked on every request.",
      "properties": {
        "image_uuid": {
          "type": "string"
        },
        "content_type": {
          "type": "string"
        },
        "data": {
          "type": "string",
          "contentEncoding": "base64"
        }
      },
      "required": [
        "image_uuid",
        "content_type",
        "data"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "uuid",
    "kind",
    "status",
    "title",
    "content",
    "observed_at",
    "published_at",
    "valid_until",
    "outdated",
    "previous_entry_uuid",
    "follow_up_uuids",
    "image_uuid",
    "image_description",
    "revision",
    "served_at",
    "feedback",
    "own",
    "shared"
  ],
  "$defs": {
    "JournalRevision": {
      "type": "object",
      "properties": {
        "number": {
          "type": "integer"
        },
        "published_at": {
          "type": "string",
          "format": "date-time"
        },
        "entry": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string"
            },
            "content": {
              "type": "string"
            },
            "image_description": {
              "type": [
                "string",
                "null"
              ]
            },
            "status": {
              "type": "string",
              "enum": [
                "draft",
                "published",
                "dismissed",
                "retracted"
              ]
            },
            "observed_at": {
              "type": "string",
              "format": "date-time"
            },
            "valid_until": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "image_uuid": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "title",
            "content",
            "image_description",
            "status",
            "observed_at",
            "valid_until",
            "image_uuid"
          ]
        }
      },
      "required": [
        "number",
        "published_at",
        "entry"
      ]
    }
  }
}