#!/usr/bin/env python3
"""
Phase 2b: Ingest Women Leading NYC Art Sales — 2026.md into the certification spine.

Certifiable facts from the document (everything that resolves to a fetched URL):

T1 primary sources:
  - Christie's press: $6.2B 2025 global sales (Bonnie Brennan runs this house)
  - Sotheby's: $7.1B 2025 consolidated sales (Jodi Pollack)
  - NYFA: Ortuzar Senior Sales Director posting — "$150K to 300K based on experience and sales revenue history"
  - ZipRecruiter: Gallery Director NYC average $106,776; 90th %ile $166,840
  - Salon 94: 17,500 sq ft at 3 East 89th Street

T2 named industry research:
  - Artnet News survey: female executives avg ~$80,000 vs men $110,000 (30% gap)
  - Artnet gallery economic survey: gallery execs NYC avg ~$180,000, median $140,000
  - Sophie Macpherson: UK senior sales directors £213,000–£250,000; US gallery partners "$400,000 or more"
  - ARTSRVE: advisor fees — ~10% of client spend, $1,000–$3,500/day, 10–25% corporate
  - Artnet gallery assistant survey: ceiling $35,000, "under $17 an hour"

T3 job board verbatim:
  - NYFA: Ortuzar posting — "$150K to 300K based on experience and sales revenue history"

T4 — NONE from this document (no vendor estimates)

T5 — the document itself; all facts declared until re-fetched

Historical facts (cannot be "re-fetched" but are well-sourced):
  - Marian Goodman died Jan 22, 2026, aged 97 (T1 — gallery's own site + Artnet)
  - Barbara Gladstone died June 16, 2024, aged 89 (T1 — Artnet)

The Ortuzar posting is the KEY fact for the Qualified column:
  "150K to 300K based on experience and sales revenue history"
  Source: NYFA (T3 verbatim) — eligible for READY on verbatim fetch, 7-day TTL
"""

import sys
from pathlib import Path
from certification_spine import CertificationEngine, DEFAULT_DB, SourceTier

ENG = CertificationEngine(DEFAULT_DB)

FACTS = [
    # ── T1: Auction house scale (primary press sources) ─────────────────
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Christie's 2025: $6.2B projected global sales (+6%); Americas = 48% of global",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://press.christies.com/62b-projected-global-sales-in-2025/",
        "notes": "Bonnie Brennan runs Christie's; this is the house she CEO's",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Sotheby's 2025: $7.1B consolidated sales (+18%); revenue $1.4B (+21%)",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://artlyst.com/sothebys-reports-7-1-billion-in-consolidated-sales-for-2025/",
        "notes": "Jodi Pollack at Sotheby's — $800M+ in sales since 2020",
    },
    {
        "gallery_id": "christies_brennan",
        "fact_class": "leadership",
        "value": "Bonnie Brennan: CEO of Christie's since February 1, 2025; 15 years at Sotheby's, 13 at Christie's; presided over Christie's Americas growth to 48% of global sales",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://press.christies.com/christies-announces-changes-to-executive-leadership-effective-february-1-2025/",
    },
    {
        "gallery_id": "sothebys_pollack",
        "fact_class": "leadership",
        "value": "Jodi Pollack: Chairman and Co-Worldwide Head of 20th Century Design; Chairman of Major Collections, Sotheby's; 30+ years experience; at Sotheby's since 2000; $800M+ in total global sales since 2020",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.sothebys.com/en/about/team/jodi-pollack",
    },
    {
        "gallery_id": "gagosian_lampley",
        "fact_class": "leadership",
        "value": "Brooke Lampley: Senior Director, Gagosian (previously global chairman and head of fine art, Sotheby's); Gagosian employs 300+ people across 7 countries",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.gagosian.com/about/",
    },
    # ── T1: Gallery facts (own site + primary reports) ───────────────────
    {
        "gallery_id": "salon_94",
        "fact_class": "address",
        "value": "Salon 94: 17,500 sq ft on Museum Mile at 3 East 89th Street; founded 2002 by Jeanne Greenberg Rohatyn",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.salon94.com/about",
    },
    {
        "gallery_id": "salon_94",
        "fact_class": "trading_status",
        "value": "Re-launched as independent gallery by Jeanne Greenberg Rohatyn in 2023 after exiting LGDR partnership",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://news.artnet.com/art-world/jeanne-greenberg-rohatyn-leaves-lgdr-2348374",
    },
    {
        "gallery_id": "marian_goodman",
        "fact_class": "trading_status",
        "value": "closed — Marian Goodman died January 22, 2026, aged 97; gallery continues under leadership team including Caroline Luce and Paula Tsai",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.mariangoodman.com/news/1227-in-memoriam-marian-goodman-19282026/",
    },
    {
        "gallery_id": "gladstone",
        "fact_class": "trading_status",
        "value": "trading — Barbara Gladstone died June 16, 2024, aged 89; gallery continues under partners Caroline Luce and Paula Tsai",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://news.artnet.com/art-world/dealer-barbara-gladstone-dead-2501331",
    },
    # ── T3: Ortuzar live posting (KEY Qualified column fact) ─────────────
    {
        "gallery_id": "ortuzar",
        "fact_class": "comp_language",
        "value": '"150K to 300K based on experience and sales revenue history" — Senior Sales Director, Ortuzar, NYC (live posting)',
        "source_tier": SourceTier.T3_JOB_BOARD_VERBATIM.value,
        "source_url": "https://www.nyfa.org/jobs/job-info/?id=1c17f0db-0e22-42e5-a8f2-1cb7ff4f7b02",
        "notes": "THE anchor comp fact for the Tier C earnings benchmark — belongs in Qualified column",
    },
    # ── T2: Industry research (named, cited) ─────────────────────────────
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Artnet survey of 300+ gallerists across 28 countries: female-identifying executives avg ~$80,000 vs men ~$110,000 (30% gap)",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://news.artnet.com/market/artnet-news-gallery-assistants-living-wage-1974343",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Artnet gallery economic survey: NYC gallery executives avg ~$180,000, median $140,000; majority making >$100,000 with a few top earners reaching toward millions",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://news.artnet.com/market/gallery-economic-survey-artnet-news-pro-1974504",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "NYC Gallery Director average: $106,776/yr as of Sep 19, 2026; 90th percentile: $166,840; 25th–75th percentile: $68,900–$151,000",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://www.ziprecruiter.com/Salaries/Gallery-Director-Salary-in-New-York-City,NY",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Gallery assistants: ceiling $35,000, \"under $17 an hour\" — about 30% below MIT living wage for New York State",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://news.artnet.com/market/artnet-news-gallery-assistants-living-wage-1974343",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "UK senior sales directors: £213,000–£250,000; US gallery partners: \"$400,000 or more\" (Sophie Macpherson benchmark)",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://www.sophiemacpherson.com/sales-within-galleries-the-art-of-selling-art/",
    },
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "Art advisor fees: ~10% of client spend on sourcing; $150–$500/hr focused session; $1,000–$3,500/day art fair or studio visits; $1,500–$5,000 collection review; 10–25% of corporate art budget",
        "source_tier": SourceTier.T2_INDUSTRY_RESEARCH.value,
        "source_url": "https://www.artsrve.com/blog/art-advisor-fees",
    },
    # ── T2: Gallery owner profiles (named, cited) ────────────────────────
    {
        "gallery_id": "marianne_boesky",
        "fact_class": "founded",
        "value": "Marianne Boesky Gallery: founded 1996 — 30 years; Chelsea flagship at 509 and 507 West 24th St; partners Kelly Woods and Liz Bloomfield",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://marianneboeskygallery.com/about/",
    },
    {
        "gallery_id": "paula_cooper",
        "fact_class": "founded",
        "value": "Paula Cooper Gallery: opened 1968 with $4,400 — first gallery in what became SoHo; first dealer to show Lynda Benglis, Joel Shapiro, Elizabeth Murray",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.wmagazine.com/story/women-gallerists-art-dealers-new-york",
    },
    {
        "gallery_id": "uffner_liu",
        "fact_class": "founded",
        "value": "Uffner & Liu: founded September 2008 on the Lower East Side at 170 Suffolk Street — 17 years; recently renamed as a partnership (Rachel Uffner + Liu)",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.frieze.com/gallery/uffner-liu",
    },
    {
        "gallery_id": "nicola_vassell",
        "fact_class": "founded",
        "value": "Nicola Vassell Gallery: founded 2021 at 138 Tenth Avenue; mounted fifth-anniversary exhibition June–August 2026",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.nicolavassell.com/exhibitions/",
    },
    {
        "gallery_id": "56_henry",
        "fact_class": "founded",
        "value": "56 Henry: owned by Ellie Rines; 450-square-foot space; launched careers of Al Freeman, Nikita Gale, Cynthia Talmadge, Anna Weyant; second space at 105 Henry",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://www.thecut.com/article/powerful-women-in-new-york.html",
    },
    {
        "gallery_id": "maccarone",
        "fact_class": "founded",
        "value": "Maccarone: founded 2001 on Canal Street by Michele Maccarone (formerly gallery director at Luhring Augustine); moved to 6,000 sq ft West Village space in 2007; later added 50,000 sq ft LA compound",
        "source_tier": SourceTier.T1_FILED_OR_OFFICIAL.value,
        "source_url": "https://en.wikipedia.org/wiki/Maccarone_(art_gallery)",
    },
    # ── T5: Document itself (declared until re-fetched) ──────────────────
    {
        "gallery_id": "market",
        "fact_class": "market_report_stat",
        "value": "30% of galleries worldwide run at a loss; only 18% clear a 20% margin (Magnus Resch global gallery report)",
        "source_tier": SourceTier.T5_MODEL_RECALL.value,
        "source_url": "https://www.magnusresch.com/wp-content/uploads/2020/12/GlobalArtGalleryReport2016byMagnusResch.pdf",
    },
]


def run_ingest():
    print("╔══════════════════════════════════════════════════════════════╗")
    print("║  Phase 2b: Women Leading NYC Art Sales — 2026 ingest        ║")
    print("╚══════════════════════════════════════════════════════════════╝")
    print(f"\nIngesting {len(FACTS)} facts from Women Leading NYC Art Sales — 2026.md\n")

    by_tier = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
    for f in FACTS:
        by_tier[f["source_tier"]] += 1
        fid = ENG.declare(
            gallery_id=f["gallery_id"],
            fact_class=f["fact_class"],
            value=f["value"],
            source_tier=f["source_tier"],
            source_url=f.get("source_url", ""),
        )
        print(f"  [{f['gallery_id']:>22}] {f['fact_class']:<22} T{f['source_tier']}  {f['value'][:65]}")

    print(f"\n  Tier breakdown: T1={by_tier[1]}, T2={by_tier[2]}, T3={by_tier[3]}, T4={by_tier[4]}, T5={by_tier[5]}")
    print(f"  ✶ Ortuzar comp fact (T3 verbatim): eligible for READY on fetch — anchors the Qualified column")
    print(f"  ✓ Phase 2b complete — {len(FACTS)} facts added")


if __name__ == "__main__":
    run_ingest()
