{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/patternfetch-com/json-schema/patternfetch-com-brief-schema.json",
  "title": "Brief",
  "description": "Token-compact market-state brief. Returned by /v1/brief and /v1/demo.",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/patternfetch-com-api-openapi.json#/components/schemas/Brief",
  "type": "object",
  "properties": {
    "header": {
      "type": "object",
      "properties": {
        "sym": {
          "type": "string"
        },
        "tf": {
          "type": "string"
        },
        "src": {
          "type": "string",
          "enum": [
            "binance",
            "vwap-composite",
            "yahoo",
            "twelvedata"
          ],
          "description": "The venue that ACTUALLY served this series — not the one routing would have guessed. A failover shows up here."
        },
        "n": {
          "type": "integer"
        },
        "t0": {
          "type": "integer",
          "description": "first candle open time (epoch ms)"
        },
        "t1": {
          "type": "integer",
          "description": "last candle open time (epoch ms)"
        },
        "asOf": {
          "type": "integer",
          "description": "Epoch ms of the last bar in the series. What the brief is actually AS OF — not when it was requested."
        },
        "delay": {
          "type": "string",
          "enum": [
            "realtime",
            "delayed/EOD"
          ],
          "description": "Freshness class of the serving source. Equity sources are delayed/EOD; crypto is realtime."
        },
        "adjusted": {
          "type": "boolean",
          "description": "Present (true) only for equity sources, meaning the series is split/dividend adjusted. Omitted entirely for crypto."
        }
      }
    },
    "codec": {
      "type": "object",
      "description": "Compact candle codec.",
      "properties": {
        "rows": {
          "type": "string",
          "description": "Per-candle o,h,l,c,v joined by ';' (no per-row timestamp)."
        },
        "sax": {
          "type": "string",
          "description": "a-g SAX shape signature (<=8 chars)."
        },
        "precision": {
          "type": "integer",
          "description": "Decimal precision used in rows."
        }
      }
    },
    "analysis": {
      "type": "object",
      "properties": {
        "patterns": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Pattern name. Open set — new detectors add names, so do not treat this as a closed enum."
              },
              "confidence": {
                "type": "number",
                "description": "geometric quality score 0..1 (NOT a probability of profit)"
              },
              "at": {
                "type": "integer"
              },
              "span": {
                "type": "integer"
              },
              "evidence": {
                "$ref": "#/$defs/PatternEvidence"
              }
            }
          }
        },
        "levels": {
          "type": "object",
          "properties": {
            "support": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "price": {
                    "type": "number"
                  },
                  "strength": {
                    "type": "number"
                  }
                }
              }
            },
            "resistance": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "price": {
                    "type": "number"
                  },
                  "strength": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "regime": {
          "type": "object",
          "properties": {
            "trend": {
              "type": "string",
              "enum": [
                "up",
                "down",
                "range"
              ]
            },
            "strength": {
              "type": "number"
            },
            "volPct": {
              "type": "number",
              "description": "ATR as % of price"
            }
          }
        },
        "indicators": {
          "type": "object",
          "description": "Interpreted indicator states, keyed by indicator name. OPEN-ENDED: the code returns a map, so do not assume only rsi/ema are present.",
          "properties": {
            "rsi": {
              "type": "object",
              "properties": {
                "v": {
                  "type": "number"
                },
                "state": {
                  "type": "string",
                  "enum": [
                    "overbought",
                    "oversold",
                    "neutral"
                  ]
                }
              }
            },
            "ema": {
              "type": "object",
              "properties": {
                "v": {
                  "type": "number"
                },
                "state": {
                  "type": "string"
                }
              }
            }
          },
          "additionalProperties": true
        },
        "nl": {
          "type": "string",
          "description": "One-line natural-language summary the agent can act on."
        }
      }
    },
    "disclaimer": {
      "type": "string"
    },
    "methodologyUrl": {
      "type": "string"
    },
    "notice": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Caveats that change how the payload should be read — today the cross-listing warning (e.g. \"BTC\" is a US security here, not Bitcoin). Serialized as the FIRST key so it is seen before the data it qualifies. Absent when there is nothing to warn about."
    }
  },
  "$defs": {
    "LiftEvidence": {
      "type": "object",
      "description": "The pattern's measured edge over a pattern-free baseline. THIS is the number that says whether the pattern carries information, as opposed to merely riding a drifting market.",
      "properties": {
        "baseline": {
          "type": "number",
          "description": "Direction-matched unconditional rate: P(up) for a bullish pattern, P(down) for a bearish one."
        },
        "baselineN": {
          "type": "integer",
          "description": "Windows behind the baseline."
        },
        "lift": {
          "type": "number",
          "description": "hitRate - baseline, in rate points. Can be negative."
        },
        "ci95": {
          "type": "number",
          "description": "95% confidence-interval half-width on lift."
        },
        "ci95Clustered": {
          "type": "number",
          "description": "Half-width widened for overlapping windows. Present when the occurrences are not independent; it is the more honest of the two."
        },
        "informative": {
          "type": "boolean",
          "description": "Whether lift is distinguishable from zero given the interval. False is a normal, honest outcome — most patterns most of the time."
        },
        "reading": {
          "type": "string",
          "enum": [
            "above-baseline",
            "below-baseline",
            "indistinguishable-from-baseline"
          ],
          "description": "Plain-language verdict, so a caller does not have to redo the statistics."
        }
      }
    },
    "PatternEvidence": {
      "type": "object",
      "description": "Backtested evidence for a detected pattern. Absent when the pattern has no sufficiently-powered evidence bucket — an omitted `evidence` means \"we have not measured this\", never \"it does not work\".",
      "properties": {
        "hitRate": {
          "type": "number",
          "description": "Directional hit rate over the horizon, 0..1."
        },
        "horizon": {
          "type": "integer",
          "description": "Bars forward the outcome was measured over."
        },
        "n": {
          "type": "integer",
          "description": "Independent historical occurrences."
        },
        "scope": {
          "type": "string",
          "description": "Corpus the rate was measured over."
        },
        "ci95": {
          "type": "number",
          "description": "95% confidence-interval half-width on hitRate."
        },
        "lift": {
          "$ref": "#/$defs/LiftEvidence"
        }
      }
    }
  }
}