{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://pivlu.com/schema.json",
 "title": "Pivlu content schema",
 "description": "All editorial content on pivlu.com is JSON written by the GPT pipeline into site-v2/content/<type>s/<id>.json and validated against this file before build. Eight document types: card, investigation, product, direction, playbook, essay (graded direction essay), opportunity, dossier. Every reader-visible text is a bitext {zh, en}; en may be an empty string until the English site opens. Every factual sentence is a claim with status verified | inferred | not_found; verified requires source_url. The generator never invents numbers: metrics it cannot compute are rendered as 暂无估算 / 暂无数据. fixture:true marks layout-test documents in content/fixtures/; they are dropped unless build.py --fixtures is passed and must never be deployed (the build writes out/.fixtures-included, and the publish script must refuse it).",
 "$defs": {
  "bitext": {
   "type": "object",
   "required": [
    "zh"
   ],
   "properties": {
    "zh": {
     "type": "string"
    },
    "en": {
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "store": {
   "type": "string",
   "enum": [
    "apple",
    "github",
    "hn",
    "web",
    "chrome",
    "other"
   ],
   "description": "apple = App Store (product_id ios_<appleId>), github = gh_<repoId>, hn = hn_<storyId>, web = web_<slug>, chrome = ext_<slug>."
  },
  "claim_status": {
   "type": "string",
   "enum": [
    "verified",
    "inferred",
    "not_found"
   ]
  },
  "claim": {
   "type": "object",
   "required": [
    "text",
    "status"
   ],
   "properties": {
    "text": {
     "$ref": "#/$defs/bitext"
    },
    "status": {
     "$ref": "#/$defs/claim_status"
    },
    "source_url": {
     "type": "string",
     "format": "uri"
    }
   },
   "if": {
    "properties": {
     "status": {
      "const": "verified"
     }
    }
   },
   "then": {
    "required": [
     "source_url"
    ]
   },
   "additionalProperties": false
  },
  "source": {
   "type": "object",
   "required": [
    "title",
    "url"
   ],
   "properties": {
    "title": {
     "type": "string"
    },
    "url": {
     "type": "string",
     "format": "uri"
    },
    "accessed": {
     "type": "string",
     "format": "date"
    }
   },
   "additionalProperties": false
  },
  "grade": {
   "type": "string",
   "enum": [
    "S",
    "A",
    "B",
    "C",
    "D",
    "E"
   ],
   "description": "S 立刻值得跟; A 值得跟; B 有条件地跟; C 看看就好; D 不建议; E 坑。Shown with grade_reason."
  },
  "metric": {
   "type": "object",
   "description": "Exactly one key number per card. basis says what was counted and when. estimate:true renders the 估算 label.",
   "required": [
    "label",
    "value",
    "basis",
    "estimate",
    "source"
   ],
   "properties": {
    "label": {
     "$ref": "#/$defs/bitext"
    },
    "value": {
     "type": [
      "number",
      "string"
     ]
    },
    "from": {
     "type": [
      "number",
      "string"
     ],
     "description": "Optional earlier value, rendered as from → value."
    },
    "unit": {
     "$ref": "#/$defs/bitext"
    },
    "basis": {
     "$ref": "#/$defs/bitext"
    },
    "estimate": {
     "type": "boolean"
    },
    "source": {
     "type": "string",
     "description": "Shown verbatim: Apple App Store, GitHub, Hacker News, ..."
    }
   },
   "additionalProperties": false
  },
  "revenue_band": {
   "type": "object",
   "description": "Only present when our revenue model exists for that product. Absent → page shows 暂无估算.",
   "required": [
    "low_usd",
    "high_usd",
    "period",
    "method",
    "error_note"
   ],
   "properties": {
    "low_usd": {
     "type": "number"
    },
    "high_usd": {
     "type": "number"
    },
    "period": {
     "type": "string",
     "enum": [
      "month"
     ]
    },
    "method": {
     "$ref": "#/$defs/bitext"
    },
    "error_note": {
     "$ref": "#/$defs/bitext"
    },
    "founder_reported_usd": {
     "type": "number"
    },
    "founder_source_url": {
     "type": "string",
     "format": "uri"
    }
   },
   "additionalProperties": false
  },
  "curve_point": {
   "type": "object",
   "required": [
    "date"
   ],
   "properties": {
    "date": {
     "type": "string",
     "format": "date"
    },
    "countries_free": {
     "type": "integer"
    },
    "countries_paid": {
     "type": "integer"
    },
    "countries_grossing": {
     "type": "integer"
    },
    "best_rank": {
     "type": "integer"
    },
    "rating_count": {
     "type": "integer"
    },
    "rating": {
     "type": "number"
    },
    "stars": {
     "type": "integer"
    },
    "forks": {
     "type": "integer"
    }
   }
  },
  "common": {
   "type": "object",
   "properties": {
    "fixture": {
     "type": "boolean"
    },
    "updated": {
     "type": "string",
     "format": "date"
    }
   }
  },
  "card": {
   "type": "object",
   "description": "One row in the daily 市场脉搏 feed (/ and /daily/<date>/). The generator builds mechanical cards from radar.db; the pipeline overrides a card by writing content/cards/<date>.json as an array, or one file per card, matching product_id. A card may also point at a product that is not in the DB (web/chrome) — then it must carry product_url.",
   "required": [
    "type",
    "date",
    "product_id",
    "title",
    "store",
    "metric"
   ],
   "properties": {
    "type": {
     "const": "card"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "product_id": {
     "type": "string"
    },
    "title": {
     "$ref": "#/$defs/bitext",
     "description": "Story headline, ≤ 40 Chinese characters."
    },
    "trigger": {
     "$ref": "#/$defs/claim",
     "description": "One sentence: what set it off."
    },
    "store": {
     "$ref": "#/$defs/store"
    },
    "launch_date": {
     "type": "string",
     "format": "date"
    },
    "direction": {
     "type": "string",
     "description": "direction slug"
    },
    "metric": {
     "$ref": "#/$defs/metric"
    },
    "link": {
     "type": "string",
     "description": "Site-relative investigation URL, e.g. /news/<slug>/"
    },
    "product_url": {
     "type": "string",
     "format": "uri"
    },
    "status": {
     "type": "string",
     "enum": [
      "auto",
      "investigated",
      "withdrawn"
     ]
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "investigation": {
   "type": "object",
   "description": "Full investigation behind a card → /news/<slug>/. Fixed sections, every sentence a claim. The top block (what_it_is / why_it_surged / how_to_follow) is rendered first because readers decide there.",
   "required": [
    "type",
    "slug",
    "date",
    "product_id",
    "title",
    "summary",
    "what_it_is",
    "why_it_surged",
    "who_made_it",
    "how_it_earns",
    "bad_review_opportunities",
    "how_to_follow",
    "uncertain",
    "sources"
   ],
   "properties": {
    "type": {
     "const": "investigation"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "updated": {
     "type": "string",
     "format": "date"
    },
    "product_id": {
     "type": "string"
    },
    "direction": {
     "type": "string"
    },
    "title": {
     "$ref": "#/$defs/bitext"
    },
    "summary": {
     "$ref": "#/$defs/bitext"
    },
    "grade": {
     "$ref": "#/$defs/grade"
    },
    "grade_reason": {
     "$ref": "#/$defs/bitext"
    },
    "revenue_band": {
     "$ref": "#/$defs/revenue_band"
    },
    "what_it_is": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     },
     "minItems": 1
    },
    "why_it_surged": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     },
     "minItems": 1
    },
    "who_made_it": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "timeline": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "date",
       "text"
      ],
      "properties": {
       "date": {
        "type": "string"
       },
       "text": {
        "$ref": "#/$defs/bitext"
       },
       "source_url": {
        "type": "string",
        "format": "uri"
       }
      }
     }
    },
    "how_it_earns": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "bad_review_opportunities": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "rising_with_it": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "product_ids rising in the same direction"
    },
    "how_to_follow": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     },
     "minItems": 3,
     "maxItems": 3
    },
    "uncertain": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     }
    },
    "curve": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/curve_point"
     },
     "description": "Optional; empty → computed from radar.db."
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     },
     "minItems": 1
    },
    "status": {
     "type": "string",
     "enum": [
      "published",
      "withdrawn"
     ]
    },
    "withdrawn_reason": {
     "$ref": "#/$defs/bitext"
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "product": {
   "type": "object",
   "description": "Editorial overlay for one product → merged into /apps/<product_id>/ (or /github/<id>/). The DB page exists without this file; this adds the one-liner, grade and revenue band.",
   "required": [
    "type",
    "product_id",
    "name",
    "store"
   ],
   "properties": {
    "type": {
     "const": "product"
    },
    "product_id": {
     "type": "string"
    },
    "name": {
     "type": "string"
    },
    "store": {
     "$ref": "#/$defs/store"
    },
    "one_line": {
     "$ref": "#/$defs/bitext"
    },
    "developer": {
     "type": "string"
    },
    "developer_url": {
     "type": "string",
     "format": "uri"
    },
    "launch_date": {
     "type": "string",
     "format": "date"
    },
    "price": {
     "type": "string"
    },
    "genre": {
     "type": "string"
    },
    "direction": {
     "type": "string"
    },
    "product_url": {
     "type": "string",
     "format": "uri"
    },
    "grade": {
     "$ref": "#/$defs/grade"
    },
    "grade_reason": {
     "$ref": "#/$defs/bitext"
    },
    "revenue_band": {
     "$ref": "#/$defs/revenue_band"
    },
    "curve": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/curve_point"
     }
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     }
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "direction": {
   "type": "object",
   "description": "A direction (方向) → /dir/<slug>/ : who is rising (from DB), who builds, who made money (from investigations). match rules assign DB rows automatically; higher priority wins.",
   "required": [
    "type",
    "slug",
    "name",
    "summary"
   ],
   "properties": {
    "type": {
     "const": "direction"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "name": {
     "$ref": "#/$defs/bitext"
    },
    "summary": {
     "$ref": "#/$defs/bitext"
    },
    "match": {
     "type": "object",
     "properties": {
      "apple_genres": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "keywords": {
       "type": "array",
       "items": {
        "type": "string"
       }
      }
     }
    },
    "priority": {
     "type": "integer"
    },
    "who_is_rising": {
     "$ref": "#/$defs/bitext"
    },
    "who_builds": {
     "$ref": "#/$defs/bitext"
    },
    "who_made_money": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "nobody_is_doing": {
     "$ref": "#/$defs/bitext"
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "playbook": {
   "type": "object",
   "description": "打法 → /plays/<slug>/ : a reusable how-to distilled from 5–10 cards, with steps, real cases (card product_ids) and one counter-example.",
   "required": [
    "type",
    "slug",
    "date",
    "title",
    "summary",
    "steps",
    "cases",
    "counter_example",
    "sources"
   ],
   "properties": {
    "type": {
     "const": "playbook"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "updated": {
     "type": "string",
     "format": "date"
    },
    "title": {
     "$ref": "#/$defs/bitext"
    },
    "summary": {
     "$ref": "#/$defs/bitext"
    },
    "direction": {
     "type": "string"
    },
    "fits_when": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     },
     "description": "When this play fits you"
    },
    "steps": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "title",
       "detail"
      ],
      "properties": {
       "title": {
        "$ref": "#/$defs/bitext"
       },
       "detail": {
        "$ref": "#/$defs/bitext"
       },
       "effort": {
        "$ref": "#/$defs/bitext"
       }
      }
     },
     "minItems": 3
    },
    "cases": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "product_id",
       "note"
      ],
      "properties": {
       "product_id": {
        "type": "string"
       },
       "name": {
        "type": "string"
       },
       "link": {
        "type": "string"
       },
       "note": {
        "$ref": "#/$defs/claim"
       }
      }
     },
     "minItems": 1
    },
    "counter_example": {
     "type": "object",
     "required": [
      "name",
      "note"
     ],
     "properties": {
      "product_id": {
       "type": "string"
      },
      "name": {
       "type": "string"
      },
      "note": {
       "$ref": "#/$defs/claim"
      }
     }
    },
    "pitfalls": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     }
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     }
    },
    "status": {
     "type": "string",
     "enum": [
      "published",
      "withdrawn"
     ]
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "essay": {
   "type": "object",
   "description": "Graded direction essay (方向长文) → /m/<slug>/ . Long form, S–E grade for the whole direction, sections are free but every paragraph is a claim list.",
   "required": [
    "type",
    "slug",
    "date",
    "direction",
    "title",
    "summary",
    "grade",
    "grade_reason",
    "sections",
    "sources"
   ],
   "properties": {
    "type": {
     "const": "essay"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "updated": {
     "type": "string",
     "format": "date"
    },
    "direction": {
     "type": "string"
    },
    "title": {
     "$ref": "#/$defs/bitext"
    },
    "summary": {
     "$ref": "#/$defs/bitext"
    },
    "grade": {
     "$ref": "#/$defs/grade"
    },
    "grade_reason": {
     "$ref": "#/$defs/bitext"
    },
    "sections": {
     "type": "array",
     "minItems": 3,
     "items": {
      "type": "object",
      "required": [
       "heading",
       "claims"
      ],
      "properties": {
       "heading": {
        "$ref": "#/$defs/bitext"
       },
       "claims": {
        "type": "array",
        "items": {
         "$ref": "#/$defs/claim"
        }
       }
      }
     }
    },
    "products": {
     "type": "array",
     "items": {
      "type": "string"
     },
     "description": "product_ids discussed"
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     }
    },
    "status": {
     "type": "string",
     "enum": [
      "published",
      "withdrawn"
     ]
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "opportunity": {
   "type": "object",
   "description": "机会库 entry → /o/<slug>/ and the list at /o/. status tells whether the window is open; window says how long we think it stays open (an inference, always labelled).",
   "required": [
    "type",
    "slug",
    "date",
    "title",
    "summary",
    "status",
    "window",
    "why_now",
    "how_to_enter",
    "risks",
    "sources"
   ],
   "properties": {
    "type": {
     "const": "opportunity"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "updated": {
     "type": "string",
     "format": "date"
    },
    "direction": {
     "type": "string"
    },
    "title": {
     "$ref": "#/$defs/bitext"
    },
    "summary": {
     "$ref": "#/$defs/bitext"
    },
    "status": {
     "type": "string",
     "enum": [
      "open",
      "closing",
      "closed",
      "watching"
     ],
     "description": "open 窗口开着; closing 快关; closed 已关; watching 观察中"
    },
    "window": {
     "$ref": "#/$defs/bitext",
     "description": "e.g. 约 4–8 周（推断）"
    },
    "grade": {
     "$ref": "#/$defs/grade"
    },
    "why_now": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "how_to_enter": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     }
    },
    "risks": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     }
    },
    "evidence_products": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     }
    },
    "fixture": {
     "type": "boolean"
    }
   }
  },
  "dossier": {
   "type": "object",
   "description": "产品档案 → /p/<slug>/ : a compact profile of a product that is not necessarily on a chart (web products, launches), with the same fixed top block as an investigation but shorter.",
   "required": [
    "type",
    "slug",
    "date",
    "name",
    "store",
    "product_url",
    "what_it_is",
    "how_it_earns",
    "sources"
   ],
   "properties": {
    "type": {
     "const": "dossier"
    },
    "slug": {
     "type": "string",
     "pattern": "^[a-z0-9-]+$"
    },
    "date": {
     "type": "string",
     "format": "date"
    },
    "updated": {
     "type": "string",
     "format": "date"
    },
    "name": {
     "type": "string"
    },
    "store": {
     "$ref": "#/$defs/store"
    },
    "product_url": {
     "type": "string",
     "format": "uri"
    },
    "product_id": {
     "type": "string"
    },
    "direction": {
     "type": "string"
    },
    "one_line": {
     "$ref": "#/$defs/bitext"
    },
    "grade": {
     "$ref": "#/$defs/grade"
    },
    "grade_reason": {
     "$ref": "#/$defs/bitext"
    },
    "revenue_band": {
     "$ref": "#/$defs/revenue_band"
    },
    "what_it_is": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "who_made_it": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "how_it_earns": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/claim"
     }
    },
    "what_to_borrow": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/bitext"
     }
    },
    "sources": {
     "type": "array",
     "items": {
      "$ref": "#/$defs/source"
     }
    },
    "fixture": {
     "type": "boolean"
    }
   }
  }
 },
 "oneOf": [
  {
   "$ref": "#/$defs/card"
  },
  {
   "$ref": "#/$defs/investigation"
  },
  {
   "$ref": "#/$defs/product"
  },
  {
   "$ref": "#/$defs/direction"
  },
  {
   "$ref": "#/$defs/playbook"
  },
  {
   "$ref": "#/$defs/essay"
  },
  {
   "$ref": "#/$defs/opportunity"
  },
  {
   "$ref": "#/$defs/dossier"
  }
 ]
}