# -*- coding: utf-8 -*-
"""
HASHFLOPS Mining Companies Catalog v1.1 — data definitions (release 2026-10-17).

Single source of truth for the release. Everything below is either carried over from the
v1.0 workbook (dump in repro/v1_0_workbook_dump.json), taken from the project's validated
upstream packages (Mining Cost Standard v1.0 2026Q2 — fingerprint 7922aeb6…8664b; Mining NAV
Standard v1.1 — data cut 2026-10-15, fingerprint 98f32a38…d273), or entered here with a
primary-source citation. No estimates: anything not disclosed stays ND.
"""
import json, os, datetime

HERE = os.path.dirname(os.path.abspath(__file__))
REPRO = os.path.join(HERE, '..', 'repro')

RELEASE = {
    'catalog_name': 'HASHFLOPS Mining Companies Catalog',
    'version': '1.1',
    'release_date': '2026-10-17',
    'composition_date': '2026-10-17',
    'data_cut': 'Q2 2026 filings (through 2026-09-29) + market data 2026-10-15',
    'prior_version': '1.0 (2026-10-08)',
    'dc_ai_reference': {'version': '1.2', 'date': '2026-10-10', 'issuers': 111,
                        'file': 'dc_ai_catalog_1.2_current_catalog_2026-10-10.csv (FLOP-HASH project)'},
    'upstream': {
        'cost_standard': {'name': 'Mining Cost Standard v1.0 — 2026Q2', 'fingerprint': '7922aeb63ce8333e703163d035885d102745ff73bf4be858782197e6ce18664b'},
        'nav_standard': {'name': 'Mining NAV Standard v1.1 — data cut 2026-10-15', 'fingerprint': '98f32a38c7fff38d1a05da2966f4cef0d590672317ccb2b47784f2665febd273'},
    },
    'market_data_date': '2026-10-15',
    'refresh_calendar': ['2026-11-30', '2027-02-28', '2027-05-31', '2027-08-31'],
}

v10 = json.load(open(os.path.join(REPRO, 'v1_0_workbook_dump.json'), encoding='utf-8'))
UP = json.load(open(os.path.join(REPRO, 'upstream_inputs_extract.json'), encoding='utf-8'))
CS, NAV = UP['cost_standard'], UP['nav']

# --------------------------------------------------------------------------------------
# Sources — v1.0 registry (S001–S038) carried over verbatim + new entries for v1.1
# --------------------------------------------------------------------------------------
SOURCES = []
for s in v10['sources']:
    SOURCES.append({'source_id': s['A'], 'document': s['B'], 'url': s['C'], 'doc_date': s['D'], 'provenance': s['E'], 'retrieved': s['F'], 'added_in_version': '1.0'})

def add_src(sid, doc, url, date, prov, retrieved='2026-10-17'):
    SOURCES.append({'source_id': sid, 'document': doc, 'url': url, 'doc_date': date, 'provenance': prov, 'retrieved': retrieved, 'added_in_version': '1.1'})

add_src('S039', 'Keel Infrastructure (ex-Bitfarms) — US redomiciliation plan and intent to rebrand; exit from Bitcoin mining', 'https://ir.keelinfra.com/news-releases/news-release-details/bitfarms-announces-us-redomiciliation-plan-and-intent-rebrand', '2026-02-06', 'PRIMARY · corporate IR release')
add_src('S040', 'Cango Inc. — Q2 2026 unaudited financial results (Form 6-K, Exhibit 99.1, acc. 0001493152-26-040816)', CS['CANG']['url'], '2026-08-31', 'PRIMARY · SEC EDGAR; values via Mining Cost Standard v1.0 (XBRL/text, blind-verified)')
add_src('S041', 'PowerCompute, Inc. (ex-LM Funding America) — Form 10-Q for the quarter ended 2026-06-30', NAV['LMFA']['filing_url'], '2026-08-14', 'PRIMARY · SEC EDGAR; values via Mining NAV Standard v1.1')
_cs_docs = {
    'MARA': 'MARA Holdings — Form 10-Q Q2 2026', 'RIOT': 'Riot Platforms — Form 10-Q Q2 2026', 'CLSK': 'CleanSpark — Form 10-Q Q3 FY2026 (quarter ended 2026-06-30)',
    'HIVE': 'HIVE Digital Technologies — Form 10-Q Q1 FY2027 (quarter ended 2026-06-30)', 'IREN': 'IREN Limited — Form 10-K FY2026 (Q4 derived 12M−9M)',
    'CIFR': 'Cipher Digital — Form 10-Q Q2 2026', 'CORZ': 'Core Scientific — Form 10-Q Q2 2026', 'WULF': 'TeraWulf — Form 10-Q Q2 2026',
    'BTDR': 'Bitdeer Technologies — Form 6-K Q2 2026 results (Exhibit 99.1)', 'ABTC': 'American Bitcoin — Form 10-Q Q2 2026',
    'BTBT': 'Bit Digital — Form 10-Q Q2 2026', 'HUT': 'Hut 8 — Form 10-Q Q2 2026', 'KEEL': 'Keel Infrastructure — Form 10-Q Q2 2026',
    'FUFU': 'BitFuFu — Form 6-K Q2 2026 results (Exhibit 99.1)',
}
_cs_sid = {}
_i = 42
for t in ['MARA', 'RIOT', 'CLSK', 'HIVE', 'IREN', 'CIFR', 'CORZ', 'WULF', 'BTDR', 'ABTC', 'BTBT', 'HUT']:
    sid = f'S{_i:03d}'; _i += 1
    add_src(sid, _cs_docs[t], CS[t]['url'], CS[t]['filing_date'], 'PRIMARY · SEC EDGAR; values via Mining Cost Standard v1.0 (XBRL/text, blind-verified)')
    _cs_sid[t] = sid
_cs_sid['CANG'] = 'S040'; _cs_sid['KEEL'] = 'S002'; _cs_sid['FUFU'] = 'S008'
add_src('S054', 'Digi Power X (ex-Digihost) — Form 10-Q Q2 2026', NAV['DGXX']['filing_url'], '2026-08-14', 'PRIMARY · SEC EDGAR; values via Mining NAV Standard v1.1')
add_src('S055', 'DMG Blockchain Solutions — MD&A for the quarter ended 2026-06-30 (SEDAR+)', 'https://www.sedarplus.ca/', '2026-08-26', 'PRIMARY · SEDAR+ (generic URL; document id not captured — URL_GENERIC flag); values via Mining NAV Standard v1.1')
add_src('S056', 'Soluna Holdings — Form 10-Q Q2 2026', NAV['SLNH']['filing_url'], '2026-08-13', 'PRIMARY · SEC EDGAR; values via Mining NAV Standard v1.1')
add_src('S057', 'BTC Digital — Form 20-F FY2025', NAV['BTCT']['filing_url'], '2026-05-11', 'PRIMARY · SEC EDGAR; values via Mining NAV Standard v1.1')
add_src('S058', 'Market data — closing prices 2026-10-15 (StockAnalysis / Nasdaq history pages) × basic shares outstanding from latest filings; ADS ratio applied for ARBK (1 ADS = 2,160 ordinary shares)', 'https://stockanalysis.com/', '2026-10-15', 'SECONDARY · market data only (not used for admission); via Mining NAV Standard v1.1')
add_src('S059', 'DC/AI Public Companies Catalog 1.2 — current catalog snapshot (111 issuers)', 'project://FLOP-HASH/claude/data/inputs/dc_ai_catalog_1.2_current_catalog_2026-10-10.csv', '2026-10-10', 'INTERNAL · identity reference for the anti-join; market caps for APLD/WYFI/GLXY taken from this snapshot (quote dates 2026-10-02…07)')
add_src('S060', 'Decrypt — "Bitfarms Stock Pumps as It Dumps Bitcoin Mining for AI With Name Change, Move to US"', 'https://decrypt.co/357222/bitfarms-stock-pumps-dumps-bitcoin-mining-business', '2026-02-06', 'SECONDARY · corroborates S039; not an admission source')
add_src('S061', 'Intchains Group — First Half 2026 financial results (GlobeNewswire)', 'https://technologymagazine.com/globenewswire/3348798', '2026-08-20', 'SECONDARY · candidate screening only')
add_src('S062', 'The Block — Hyperscale Data flips Michigan site from bitcoin mining into AI', 'https://theblock.co/news/markets/2026-09-02-hyperscale-data-shares-all-time-low-company-flips-michigan-site-bitcoin-mining-into-ai-413357', '2026-09-02', 'SECONDARY · candidate screening only')

SRC_BY_ID = {s['source_id']: s for s in SOURCES}

# --------------------------------------------------------------------------------------
# Core catalog (owner = MINING). v1.0 members carried over; English admission/risk text written
# for publication; two additions (CANG, PWCM) with primary sources.
# --------------------------------------------------------------------------------------
_v10cat = {r['A']: r for r in v10['catalog']}

def mcap(t):
    x = NAV.get(t)
    return x['mcap_usd_m'] if x and x.get('mcap_usd_m') is not None else 'ND'

CORE = [
 dict(issuer_id='MIN001', ticker='ARBK', mic='XNAS', company='Argo Blockchain plc', former_identifiers='ARB (LSE ordinary shares, delisted Dec 2025); controlling shareholder Growler Mining', former_tickers='ARB',
      segment='M1', business_model='SELF_MINING', tags='', domicile='GB', name_key='argoblockchain', mining_status='ACTIVE', ai_hpc_stage='NOT_EVIDENCED',
      admission_basis='Active self-mining (pool FPPS, mined BTC sold weekly); 22,600 miners at end-2025 at Baie-Comeau (owned, 15 MW) and two Alabama sites leased from Growler (13.5 MW). No qualifying commercial AI/HPC business in the reviewed filings.',
      risks_notes='Concentrated control (Growler); restructuring; production reported in BTC-equivalent; hosted capacity at Merkle sites ended Mar/Apr 2026 so 2026 operating capacity is materially below 2025; CEO departed 2026-08-30; latest financials FY2025 (stale).',
      source_id='S001', doc_date='2026-09-03', url=_v10cat['ARBK']['P'], added_in_version='1.0', cost_tier='—', nav='yes', mcap_src='S058 (ADS price ÷ 2,160)'),
 dict(issuer_id='MIN002', ticker='KEEL', mic='XNAS', company='Keel Infrastructure Corp.', former_identifiers='Bitfarms Ltd. / BITF (Nasdaq, TSX; Canadian parent until 2026-04-01); Stronghold Digital Mining / SDIG (acquired 2025)', former_tickers='BITF;SDIG',
      segment='M1', business_model='SELF_MINING', tags='transition;wind_down;energy', domicile='US', name_key='keelinfrastructure', mining_status='WIND_DOWN_ANNOUNCED', ai_hpc_stage='ANNOUNCED',
      admission_basis='354 BTC earned in Q2 2026 at the remaining Québec sites; Bitcoin mining is still the only reportable segment (described as "legacy"). Admission rests on R02 (actual production in the latest reported quarter); exit from mining was announced (Nov 2025) and the company redomiciled/rebranded on 2026-04-01 (S039).',
      risks_notes='Wind-down in progress: US mining fully decommissioned by 2026-06-29, Paraguay sold 2026-04-21, Argentina discontinued; hashrate no longer disclosed; BTC treasury being sold down; no signed HPC/AI lease as of 2026-08-10 (sites in permitting). Automatic re-review at the Q3 2026 10-Q: zero production → EXITED → removal.',
      source_id='S002', doc_date='2026-08-10', url=_v10cat['KEEL']['P'], added_in_version='1.0', cost_tier='3', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN003', ticker='PHX', mic='XADS', company='Phoenix Group PLC', former_identifiers='', former_tickers='',
      segment='M1', business_model='SELF_MINING', tags='hosting', domicile='AE', name_key='phoenixgroup', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Operating self-mining (239.9 BTC own production in Q2 2026); Lyon AI project under development without a confirmed customer contract in the source.',
      risks_notes='JV and customer production reported separately from own; Bitzero is a minority stake (no group consolidation); own-mining revenue not broken out (share ND).',
      source_id='S003', doc_date='2026-07-16', url=_v10cat['PHX']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN004', ticker='SATO', mic='XTSX', company='SATO Technologies Corp.', former_identifiers='', former_tickers='',
      segment='M1', business_model='SELF_MINING', tags='', domicile='CA', name_key='satotechnologies', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Q2 2026 production (11 BTC) and revenue confirmed; AI hosting under discussion — the Bhutan LOI is not a binding contract.',
      risks_notes='Downclocking; liquidity constraints; post-period debt settlement; TSX Venture listing (investability); own-mining revenue not separated (share ND).',
      source_id='S004', doc_date='2026-08-26', url=_v10cat['SATO']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN005', ticker='VIP', mic='XNAS', company='Vulcan Infrastructure and Power Inc.', former_identifiers='Greenidge Generation Holdings / GREE (renamed 2026-07-20; ticker VIP from 2026-07-24)', former_tickers='GREE',
      segment='M1', business_model='SELF_MINING', tags='energy;hosting;diversified', domicile='US', name_key='vulcaninfrastructureandpower', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Own mining (6,500 miners / 1.0 EH/s installed, 0.578 EH/s operating; Q2 2026 self-mining revenue $1.7m) and third-party hosting continue; AI/HPC plans without a customer contract.',
      risks_notes='Diversified: wholesale power/capacity sales to NYISO are the dominant revenue line (H1 2026 $20.0m) — the v1.0 "total revenue" perimeter for Q2 2026 ($3.385m) excludes it, so the own-mining share is set to REVIEW until the segment table is reconciled; average-hashrate unit conflict in the 10-Q table (field not carried); controlled company (Atlas Holdings 66.1%).',
      source_id='S005', doc_date='2026-08-14', url=_v10cat['VIP']['P'], added_in_version='1.0', cost_tier='—', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN006', ticker='OLB', mic='XNAS', company='The OLB Group, Inc.', former_identifiers='', former_tickers='',
      segment='M1', business_model='SELF_MINING', tags='diversified', domicile='US', name_key='olbgroup', mining_status='ACTIVE', ai_hpc_stage='NOT_EVIDENCED',
      admission_basis='Bitcoin-mining revenue disclosed for H1 2026 ($121,461 of $2,935,595); planned DMINT spin-off not treated as completed.',
      risks_notes='Mining is 4.1% of revenue (PERIPHERAL tier); not a pure play; 61.73 BTC is cumulative production, not H1; no operational observations disclosed.',
      source_id='S006', doc_date='2026-08-14', url=_v10cat['OLB']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN007', ticker='DTCX', mic='XNAS', company='Datacentrex Inc.', former_identifiers='', former_tickers='',
      segment='M1', business_model='SELF_MINING', tags='scrypt;hashrate_marketplace', domicile='US', name_key='datacentrex', mining_status='ACTIVE', ai_hpc_stage='NOT_EVIDENCED',
      admission_basis='Operating Scrypt (DOGE/LTC) mining on own machines, hashpower sold through a marketplace (NiceHash) and settled in BTC; the "Datacentrex" name does not evidence a commercial AI/HPC business.',
      risks_notes='BTC received for hashpower is not BTC production (BTC_EQ); Scrypt economics differ from SHA-256; total revenue not disclosed in the reviewed 10-Q (share ND). Classification note: marketplace hashpower sale on own machines = M1 with tag HASHRATE_MARKETPLACE (rule R23).',
      source_id='S007', doc_date='2026-08-12', url=_v10cat['DTCX']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN008', ticker='FUFU', mic='XNAS', company='BitFuFu Inc.', former_identifiers='', former_tickers='',
      segment='M2', business_model='CLOUD_MINING', tags='self_mining;hosting', domicile='KY', name_key='bitfufu', mining_status='ACTIVE', ai_hpc_stage='NOT_EVIDENCED',
      admission_basis='Commercial cloud-mining services ($24.9m) and self-mining ($14.0m) disclosed separately for Q2 2026; AI/HPC not evidenced (Oklahoma site restricted to cryptocurrency mining under the 2026-09-28 CFIUS agreement).',
      risks_notes='15.3 EH/s is managed capacity, not own average hashrate (3.8 EH/s self-owned of 19.4 under management at 2026-09-30); customer BTC excluded from own production; Bitmain is a related-party supplier; 54 BTC pledged.',
      source_id='S008', doc_date='2026-08-17', url=_v10cat['FUFU']['P'], added_in_version='1.0', cost_tier='3', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN009', ticker='SLNH', mic='XNAS', company='Soluna Holdings, Inc.', former_identifiers='', former_tickers='',
      segment='M2', business_model='HOSTING', tags='self_mining;energy', domicile='US', name_key='solunaholdings', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Mining hosting operating (~168 MW hosting vs ~24 MW self-mining at 2026-06-30; hosting $12.65m of $15.06m Q2 revenue); HPC revenue in Q2 2026 is a confirmed zero; AI campuses at negotiation stage (Kati 2 JV with Metrobloks signed 2026-06-03 is not a tenant lease).',
      risks_notes='Prior GPU contract terminated; preferred stock and NCI rank ahead of common; no EH/s disclosed.',
      source_id='S009', doc_date='2026-08-13', url=_v10cat['SLNH']['P'], added_in_version='1.0', cost_tier='—', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN010', ticker='DRK', mic='XNAS', company='Dark Horse Technologies Inc.', former_identifiers='Sphere 3D Corp. / ANY; Cathedra Bitcoin / CBIT (merged entity; Cathedra is not a separate member)', former_tickers='ANY;CBIT',
      segment='M2', business_model='HOSTING', tags='co_mining', domicile='CA', name_key='darkhorsetechnologies', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='30 MW co-mining contract with Bitdeer (2026-06-25); the latest release states alternative AI/HPC use is not contracted.',
      risks_notes='New identity; 30 MW is contracted mining capacity, not AI; Q2 2026 financial figures not carried (ND); 10-Q publication date not captured.',
      source_id='S010', doc_date='2026-09-16', url=_v10cat['DRK']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN011', ticker='SOS', mic='XNYS', company='SOS Limited', former_identifiers='', former_tickers='',
      segment='M2', business_model='HOSTING', tags='diversified', domicile='KY', name_key='sos', mining_status='SUSPENDED', ai_hpc_stage='ANNOUNCED',
      admission_basis='Commercial hosting revenue continues ($7.5m FY2025); own mining suspended in 2025 (0 BTC); digital-asset holdings are not treated as evidence of mining.',
      risks_notes='Diversified (commodity trading dominates revenue); FY2025 total revenue conflicts between table ($154.29m) and narrative ($152.1m) → shares blocked (REVIEW); hosting ≈4.9% of revenue (PERIPHERAL tier); 20-F dated 2026-05-15 (stale).',
      source_id='S011', doc_date='2026-05-15', url=_v10cat['SOS']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN012', ticker='CAN', mic='XNAS', company='Canaan Inc.', former_identifiers='', former_tickers='',
      segment='M3', business_model='ASIC_DESIGN', tags='self_mining', domicile='KY', name_key='canaan', mining_status='ACTIVE', ai_hpc_stage='NOT_EVIDENCED',
      admission_basis='Operating designer/vendor of PoW mining ASICs (Avalon); mining ASICs are not AI accelerators. Q2 2026: equipment revenue $13.6m, own mining $17.7m, total $31.9m.',
      risks_notes='Segment basis: primary product = mining machines by rule R09 even though Q2 2026 own-mining revenue exceeded equipment sales — flagged for a TTM check (rule R25); own vs JV hashrate reported separately (10.05 EH/s installed ex-JV).',
      source_id='S012', doc_date='2026-09-08', url=_v10cat['CAN']['P'], added_in_version='1.0', cost_tier='—', nav='no', mcap_src=''),
 dict(issuer_id='MIN013', ticker='BTCT', mic='XNAS', company='BTC Digital Ltd.', former_identifiers='Meten Holding Group / Meten EdtechX (METX)', former_tickers='METX',
      segment='M3', business_model='ASIC_DISTRIBUTION', tags='self_mining;hosting;rental', domicile='KY', name_key='btcdigital', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Operating equipment resale/rental and mining: FY2025 resale 72.5% of revenue, hosting 14.8%, own mining 12.7% (14.127 BTC at 390 PH/s); AI framework announcements do not evidence a commercial service.',
      risks_notes='Customer concentration; Nasdaq compliance regained 2026-09-03; mixed algorithms (DOGE/LTC) are not summed into EH/s; treasury shifted toward ETH in 2025; latest balance sheet FY2025 (stale).',
      source_id='S013', doc_date='2026-09-04', url=_v10cat['BTCT']['P'], added_in_version='1.0', cost_tier='—', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN014', ticker='CANG', mic='XNYS', company='Cango Inc.', former_identifiers='10-for-1 share consolidation effective 2026-07-20; AI subsidiary EcoHash; legacy AutoCango used-car export', former_tickers='',
      segment='M1', business_model='SELF_MINING', tags='hosted_fleet;leased_hashrate;diversified', domicile='KY', name_key='cango', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='Q2 2026: 656 BTC mined; Bitcoin-mining revenue $47.43m of $50.78m total (93.4%); 27.58 EH/s operating at 2026-06-30 (19.84 EH/s for own account, 7.74 EH/s leased out); 1,056 BTC held. Fleet hosted at Bitmain-operated third-party sites under all-in hosting fees. AI: EcoHash Georgia site up to 3 MW, GPUs arriving, no customer contract disclosed → ANNOUNCED (rule R05).',
      risks_notes='Asset-light/hosted model (host margin embedded in cost); related-party financing (Antalpha); 873 of 1,056 BTC pledged; condensed balance sheet without notes; NYSE $1 compliance regained after the consolidation. Added in v1.1 (audit finding C4).',
      source_id='S040', doc_date='2026-08-31', url=CS['CANG']['url'], added_in_version='1.1', cost_tier='2', nav='yes', mcap_src='S058'),
 dict(issuer_id='MIN015', ticker='PWCM', mic='XNAS', company='PowerCompute, Inc.', former_identifiers='LM Funding America, Inc. / LMFA (renamed 2026-07-20; 1-for-25 reverse split 2026-07-13)', former_tickers='LMFA',
      segment='M1', business_model='SELF_MINING', tags='', domicile='US', name_key='powercompute', mining_status='ACTIVE', ai_hpc_stage='ANNOUNCED',
      admission_basis='100% self-mining with owned miners at owned sites (Calumet OK 15 MW, Columbus MS 11 MW): 27.9 BTC mined in Q2 2026, 8.1 BTC in Sep 2026; 0.763 EH/s operating / 0.85 EH/s installed at 2026-08-31. AI: one GPU sold to Vast.ai (Jul 2026) — immaterial → ANNOUNCED.',
      risks_notes='Micro-cap ($1.2m at 2026-10-15); going-concern language in the 10-Q; 267.4 BTC used in Sep 2026 to extinguish the Arch loan; small legacy specialty-finance business. Added in v1.1 (audit finding C5).',
      source_id='S041', doc_date='2026-08-14', url=NAV['LMFA']['filing_url'], added_in_version='1.1', cost_tier='—', nav='yes', mcap_src='S058'),
]
for r in CORE:
    r['security_key'] = f"{r['ticker']}:{r['mic']}"
    r['owner'] = 'MINING'
    nav_t = 'LMFA' if r['ticker'] == 'PWCM' else r['ticker']
    r['market_cap_usd_m'] = mcap(nav_t)
    if r['market_cap_usd_m'] == 'ND': r['mcap_src'] = ''

# --------------------------------------------------------------------------------------
# Financial observations (core): v1.0 rows + v1.1 precision/perimeter updates
# --------------------------------------------------------------------------------------
FIN = []
for f in v10['financials']:
    FIN.append(dict(ticker=f['A'], period=f['B'], start=f['C'], end=f['D'], currency=f['E'], total=f['F'], own_mining=f['G'], hosting_cloud=f['H'], equipment=f['I'],
                    status=f['K'], note=f['L'] or '', source_id=f['M'], doc_date=f['N'], url=f['O'], version='1.0'))
_fin = {f['ticker']: f for f in FIN}
# KEEL — replace rounded v1.0 row with XBRL segment values (Cost Standard; same 10-Q)
_fin['KEEL'].update(total=30430000, own_mining=25859000, hosting_cloud=179000, equipment='ND', status='VALUE',
    note='Segment revenue per 10-Q (XBRL, via Cost Standard v1.0): Bitcoin Mining 25,859k; Energy sales 2,386k; Electrical services 2,006k; Cryptocurrency hosting 179k. Supersedes the rounded v1.0 row ($30m, own ND).', version='1.1')
# VIP — perimeter conflict → REVIEW (audit C12)
_fin['VIP'].update(status='REVIEW', note='v1.0 total ($3.385m) excludes wholesale power/capacity sales to NYISO (H1 2026 ≈ $20.0m per 10-Q) — perimeter conflict; own-mining share blocked until the segment table is reconciled.', version='1.1')
# FUFU — cloud mining counted as thematic service revenue (M2); 3.9m hosting/other left out of the thematic lower bound
_fin['FUFU'].update(hosting_cloud=24900000, note='Cloud Mining Solutions 24.9m counted as thematic service revenue; 3.9m "hosting and others" not counted (mixed); self-mining 14.0m rounded.', version='1.1')
# CANG — new (Cost Standard, XBRL-tagged 6-K)
FIN.append(dict(ticker='CANG', period='Q2 2026', start='2026-04-01', end='2026-06-30', currency='USD', total=50780771, own_mining=47427558, hosting_cloud='ND', equipment='ND', status='VALUE',
                note='Bitcoin mining 47,427,558; other revenues 3,353,213 (6-K Q2 2026 results, via Cost Standard v1.0). Leased-out hashrate income is inside "Bitcoin mining" as reported.', source_id='S040', doc_date='2026-08-31', url=CS['CANG']['url'], version='1.1'))
# PWCM — revenue split not carried (ND); production observations in Operations
FIN.append(dict(ticker='PWCM', period='Q2 2026', start='2026-04-01', end='2026-06-30', currency='USD', total='ND', own_mining='ND', hosting_cloud='ND', equipment='ND', status='ND',
                note='Revenue lines not extracted in this release (NAV Standard carries balance-sheet and production data only); 100% self-mining per 10-Q.', source_id='S041', doc_date='2026-08-14', url=NAV['LMFA']['filing_url'], version='1.1'))

# --------------------------------------------------------------------------------------
# Operational observations: v1.0 (29) + v1.1 additions from NAV/Cost inputs for core members
# --------------------------------------------------------------------------------------
OPS = []
for o in v10['operations']:
    OPS.append(dict(ticker=o['A'], metric=o['N'], value=o['C'], status=o['D'], unit=o['E'], start=o['F'], end=o['G'], scope=o['H'], note=o['I'] or '', source_id=o['J'], doc_date=o['K'], url=o['L'], obs_id=o['M'], version='1.0'))
_oid = 100
def add_obs(ticker, metric, value, unit, start, end, scope, note, sid, url, date, status='VALUE'):
    global _oid
    OPS.append(dict(ticker=ticker, metric=metric, value=value, status=status, unit=unit, start=start, end=end, scope=scope, note=note, source_id=sid, doc_date=date, url=url, obs_id=f'O{_oid:04d}', version='1.1'))
    _oid += 1
c = CS['CANG']; u = c['url']; dte = c['filing_date']
add_obs('CANG', 'own_btc_produced', 656, 'BTC', '2026-04-01', '2026-06-30', 'OWN', 'Q2 2026 production (6-K); via Cost Standard v1.0', 'S040', u, dte)
add_obs('CANG', 'hashrate_operating', 27.58, 'EH/s', 'ND', '2026-06-30', 'OPERATING_TOTAL', 'of which 19.84 EH/s for own account and 7.74 EH/s leased out to third parties', 'S040', u, dte)
add_obs('CANG', 'hashrate_operating_own', 19.84, 'EH/s', 'ND', '2026-06-30', 'OWN_ACCOUNT', 'own-account share of operating hashrate (72%)', 'S040', u, dte)
add_obs('CANG', 'btc_treasury', 1056, 'BTC', 'ND', '2026-06-30', 'OWN_TOTAL', 'of which 873 BTC pledged (derived from carrying split in NAV v1.1)', 'S040', u, dte)
add_obs('CANG', 'btc_encumbered', 873, 'BTC', 'ND', '2026-06-30', 'LOAN_PLEDGED', 'derived from receivable-for-bitcoin-collateral carrying split (NAV v1.1) — flag DERIVED', 'S040', u, dte)
add_obs('CANG', 'facility_power_capacity', 50, 'MW', 'ND', '2026-06-30', 'ENERGIZED_OWNED', 'per NAV v1.1 inputs (energized MW owned)', 'S040', u, dte)
p = NAV['LMFA']; u = p['filing_url']; dte = p['filing_date']
add_obs('PWCM', 'own_btc_produced', 27.9, 'BTC', '2026-04-01', '2026-06-30', 'OWN', 'Q2 2026 (H1 2026: 54.2 BTC; Sep 2026: 8.1 BTC)', 'S041', u, dte)
add_obs('PWCM', 'hashrate_operating', 0.763, 'EH/s', 'ND', '2026-08-31', 'OWN_OPERATING', 'installed 0.85 EH/s', 'S041', u, dte)
add_obs('PWCM', 'hashrate_installed', 0.85, 'EH/s', 'ND', '2026-08-31', 'OWN_INSTALLED', '', 'S041', u, dte)
add_obs('PWCM', 'facility_power_capacity', 26, 'MW', 'ND', '2026-06-30', 'ENERGIZED_OWNED', 'Calumet OK 15 MW + Columbus MS 11 MW', 'S041', u, dte)
add_obs('PWCM', 'btc_treasury', 63.7, 'BTC', 'ND', '2026-09-30', 'OWN_TOTAL', 'pro forma after 267.4 BTC used to extinguish the Arch loan (Sep 2026)', 'S041', u, dte)
k = NAV['KEEL']; u = k['filing_url']; dte = k['filing_date']
add_obs('KEEL', 'own_btc_produced', 354, 'BTC', '2026-04-01', '2026-06-30', 'OWN', 'Q2 2026, Québec sites only (US decommissioned by 2026-06-29)', 'S002', u, dte)
add_obs('KEEL', 'fleet_efficiency', 18, 'J/TH', 'ND', '2026-06-30', 'REPORTED_FLEET', 'per NAV v1.1 inputs', 'S002', u, dte)
add_obs('KEEL', 'power_cost', 0.054, 'USD/kWh', '2026-01-01', '2026-06-30', 'REPORTED_FLEET', '2026 cost per kWh', 'S002', u, dte)
add_obs('KEEL', 'facility_power_capacity', 341, 'MW', 'ND', '2026-06-30', 'ENERGIZED_OWNED', 'total contracted 648 MW (HPC sites in permitting)', 'S002', u, dte)
f = NAV['FUFU']; u = f['filing_url']; dte = f['filing_date']
add_obs('FUFU', 'hashrate_managed', 19.4, 'EH/s', 'ND', '2026-09-30', 'MANAGED_TOTAL', 'of which 3.8 EH/s self-owned (20%); 6-K Sep 2026 monthly update', 'S008', u, dte)
add_obs('FUFU', 'hashrate_installed', 3.8, 'EH/s', 'ND', '2026-09-30', 'OWN_INSTALLED', 'self-owned hashrate', 'S008', u, dte)
add_obs('FUFU', 'fleet_efficiency', 16.7, 'J/TH', 'ND', '2026-09-30', 'MANAGED_FLEET', 'per NAV v1.1 inputs', 'S008', u, dte)
add_obs('FUFU', 'btc_treasury', 1388, 'BTC', 'ND', '2026-09-30', 'OWN_TOTAL', 'Sep 2026 monthly update (v1.0 row: 1,671 at 2026-06-30)', 'S008', u, dte)
s = NAV['SLNH']; u = s['filing_url']; dte = s['filing_date']
add_obs('SLNH', 'facility_power_capacity', 192, 'MW', 'ND', '2026-06-30', 'ENERGIZED_OWNED', 'hosting ~168 MW + self-mining ~24 MW; total contracted 206 MW', 'S056', u, dte)
vv = NAV['VIP']; u = vv['filing_url']; dte = vv['filing_date']
add_obs('VIP', 'hashrate_average', 0.578, 'EH/s', '2026-04-01', '2026-06-30', 'OWN_OPERATING', 'per NAV v1.1 inputs; v1.0 did not carry the 10-Q average because of a unit conflict', 'S005', u, dte)
add_obs('VIP', 'fleet_efficiency', 20.8, 'J/TH', 'ND', '2026-06-30', 'OWN_FLEET', '', 'S005', u, dte)
a = NAV['ARBK']; u = a['filing_url']; dte = a['filing_date']
add_obs('ARBK', 'facility_power_capacity', 28.5, 'MW', 'ND', '2025-12-31', 'OWNED_PLUS_LEASED', 'Baie-Comeau 15 MW owned + Alabama 13.5 MW leased from Growler; hosted Merkle capacity (145 MW) ended Mar/Apr 2026', 'S014', u, dte)
b = NAV['BTCT']; u = b['filing_url']; dte = b['filing_date']
add_obs('BTCT', 'hashrate_installed', 0.3901, 'EH/s', 'ND', '2025-12-31', 'OWN_INSTALLED', '390.1 PH/s (20-F FY2025)', 'S057', u, dte)

PLEDGE = [dict(ticker=p['A'], btc_total=p['B'], date_total=p['C'], pledged=p['D'], date_pledge=p['E'], other='Not verified') for p in v10['pledge']]
PLEDGE.append(dict(ticker='CANG', btc_total=1056, date_total='2026-06-30', pledged=873, date_pledge='2026-06-30', other='Derived pledge (NAV v1.1 carrying split) — not a disclosed count'))
PLEDGE.append(dict(ticker='PWCM', btc_total=63.7, date_total='2026-09-30', pledged=0, date_pledge='2026-09-30', other='Arch loan extinguished Sep 2026; pro forma'))

# --------------------------------------------------------------------------------------
# Routing registry (DC/AI boundary). Statuses re-based on DC/AI catalog 1.2 (10.10.2026).
# --------------------------------------------------------------------------------------
_v10r = {r['A']: r for r in v10['routing']}
def R(ticker, company, status, group, dc_seg, stage, mining_relation, action, basis, sid, date, url, **kw):
    d = dict(ticker=ticker, company=company, status=status, group_id=group, owner='DC_AI' if status in ('EXISTING_DC_AI', 'CONTROLLED_CHILD', 'PARENT_REFERENCE') else 'UNASSIGNED',
             dc_segment=dc_seg, ai_hpc_stage=stage, mining_relation=mining_relation, action=action, basis=basis, source_id=sid, doc_date=date, url=url,
             pending_since='', pending_deadline='', former_identifiers='', former_tickers='')
    d.update(kw); return d
ROUTING = [
 R('IREN', 'IREN Limited', 'EXISTING_DC_AI', 'DC078', 'S4', 'OPERATING', 'HYBRID_MINING', 'Stays in DC/AI (GPU cloud); mining metrics tracked in the exposure register, no second membership.', 'Commercial AI cloud services alongside BTC mining; thematic product = compute. Bitcoin Mining revenue FY2026 $578.2m of $707.0m (81.8%); Q2 2026 48.6%.', 'S018', '2026-08-27', _v10r['IREN']['L']),
 R('HIVE', 'HIVE Digital Technologies', 'EXISTING_DC_AI', 'DC079', 'S4', 'OPERATING', 'HYBRID_MINING', 'Stays in DC/AI.', 'BUZZ HPC provides operating GPU cloud services; mining 91.1% of Q2 2026 revenue.', 'S019', '2026-08-14', _v10r['HIVE']['L']),
 R('CORZ', 'Core Scientific', 'EXISTING_DC_AI', 'DC080', 'S5', 'OPERATING', 'MINING_TRANSITION', 'Stays in DC/AI.', 'Operating high-density colocation for HPC/AI (colocation $136.7m of $164.2m Q2 2026); self-mining 13.1%. CoreWeave merger terminated 2025-10-30.', 'S020', '2026-07-28', _v10r['CORZ']['L']),
 R('WULF', 'TeraWulf', 'EXISTING_DC_AI', 'DC081', 'S5', 'OPERATING', 'MINING_TRANSITION', 'Stays in DC/AI.', 'HPC leasing revenue $31.9m of $44.8m Q2 2026; mining 28.7%.', 'S021', '2026-08-05', _v10r['WULF']['L']),
 R('APLD', 'Applied Digital', 'EXISTING_DC_AI', 'DC082', 'S5', 'OPERATING', 'MINING_HOSTING', 'Stays in DC/AI.', 'Developer/operator of commercial HPC/AI data centers; mining hosting $37.3m of $258.7m (14.4%) in Q4 FY2026 (DC/AI 1.2).', 'S022', '2026-07-29', _v10r['APLD']['L']),
 R('HUT', 'Hut 8 (consolidates American Bitcoin, ABTC)', 'EXISTING_DC_AI', 'DC083', 'S5', 'CONTRACTED', 'MINING_TRANSITION', 'Stays in DC/AI; ABTC is the group\'s mining security (see CONTROLLED_CHILD).', 'Signed long-term AI data-center leases (admission by binding contract); Compute segment incl. consolidated ABTC = 89.7% of Q2 2026 revenue.', 'S023', '2026-08-05', _v10r['HUT']['L']),
 R('CIFR', 'Cipher Digital (ex-Cipher Mining)', 'EXISTING_DC_AI', 'DC084', 'S5', 'CONTRACTED', 'MINING_TRANSITION', 'Stays in DC/AI.', 'Signed HPC tenant contracts; mining 100% of Q2 2026 revenue (HPC revenue not yet recognized).', 'S024', '2026-08-04', _v10r['CIFR']['L'], former_identifiers='Cipher Mining Inc. (renamed 2026-02-20)'),
 R('BTDR', 'Bitdeer Technologies Group', 'EXISTING_DC_AI', 'DC097', 'S4', 'OPERATING', 'HYBRID_MINING', 'Status changed in v1.1: admitted to DC/AI 1.2 on 2026-10-10 (was PROPOSE_DC_AI / PENDING_BTDR).', 'Operating AI Cloud ($14.0m of $228.8m Q2 2026, ~6%) with external customers; self-mining + co-mining + cloud hashrate = 84.5% of revenue; 69.5 EH/s average, 1,752 MW.', 'S028', '2026-09-17', _v10r['BTDR']['L']),
 R('WYFI', 'WhiteFiber Inc.', 'EXISTING_DC_AI', 'DC098', 'S4', 'OPERATING', 'ND', 'Status changed in v1.1: DC/AI 1.2 selected WYFI as the group\'s security (BTBT not added); was CONTROLLED_CHILD / PENDING_BTBT.', 'GPU cloud ($23.8m) + colocation ($4.7m) Q2 2026; controlled by Bit Digital (~69.6%, consolidated). WhiteFiber itself never mined.', 'S031', '2026-08-13', _v10r['WYFI']['L']),
 R('GLXY', 'Galaxy Digital', 'EXISTING_DC_AI', 'DC099', 'S5', 'OPERATING', 'FORMER_MINING', 'New in v1.1 reference (added to DC/AI 1.2 on 2026-10-10).', 'Helios campus leased to CoreWeave (data-center leasing revenue $18.9m Q2 2026); proprietary mining wound down in 2025.', 'S059', '2026-10-10', 'https://investor.galaxy.com/node/11461/pdf'),
 R('BTBT', 'Bit Digital, Inc.', 'PARENT_REFERENCE', 'DC098', 'S4', 'OPERATING', 'HYBRID_RESIDUAL', 'Parent of the DC098 group (WYFI is the selected security); not a member of either composition; was PROPOSE_DC_AI / PENDING_BTBT in v1.0.', 'Residual hosted mining: 32 BTC and $2.37m of $32.1m Q2 2026 revenue (7.4%), winding down; ETH staking; consolidates WhiteFiber.', _cs_sid['BTBT'], CS['BTBT']['filing_date'], CS['BTBT']['url']),
 R('ABTC', 'American Bitcoin Corp.', 'CONTROLLED_CHILD', 'DC083', 'S5', 'PARENT_CONTRACTED', 'PURE_MINING', 'Reference security of the HUT group (~80% owned, consolidated); not a separate member under rule R06. Child exception (rule R24) proposed, not applied in v1.1.', 'Pure Bitcoin miner: 932 BTC mined Q2 2026 (100% of revenue), 25.0 EH/s deployed, 8,002 BTC held; fully hosted at Hut 8 under related-party agreements.', _cs_sid['ABTC'], CS['ABTC']['filing_date'], CS['ABTC']['url'], former_identifiers='Gryphon Digital Mining / GRYP (merger 2025); 1-for-15 reverse split 2026-07-02', former_tickers='GRYP'),
 R('MARA', 'MARA Holdings, Inc.', 'PENDING_DC_AI', 'PENDING_MARA', 'S4', 'OPERATING', 'HYBRID_MINING', 'Transfer proposal not yet decided by DC/AI (not in 1.2). Rule R21: if not admitted by 2026-11-30 the group returns to the mining core with tag AI_PENDING.', 'Controlled Exaion (private cloud/AI/HPC services) acquired; mining 97.2% of Q2 2026 revenue; 70.3 EH/s deployed; 35,577 BTC held.', 'S025', '2026-08-06', _v10r['MARA']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
 R('RIOT', 'Riot Platforms, Inc.', 'PENDING_DC_AI', 'PENDING_RIOT', 'S5', 'OPERATING', 'HYBRID_MINING', 'As MARA (rule R21).', 'Data Center segment revenue $23.2m Q2 2026 (AMD lease 25 MW + 25 MW amendment); Aug 2026 tenant lease with a frontier-AI lab for 191 MW (subsequent event); mining 65.3% of revenue; 37.2 EH/s average.', 'S026', '2026-08-10', _v10r['RIOT']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
 R('CLSK', 'CleanSpark, Inc.', 'PENDING_DC_AI', 'PENDING_CLSK', 'S5', 'CONTRACTED', 'HYBRID_MINING', 'As MARA (rule R21). Note: a binding 20-year lease is the same criterion under which HUT and CIFR were admitted to DC/AI.', 'Binding 20-year data-center lease at Sandersville (contract value is not current revenue); mining 100% of Q2 2026 revenue; 42.6 EH/s average; 12,205 BTC at quarter end.', 'S027', '2026-07-14', _v10r['CLSK']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
 R('DGXX', 'Digi Power X Inc.', 'PENDING_DC_AI', 'PENDING_DGXX', 'S5', 'OPERATING', 'RESIDUAL_MINING', 'As MARA (rule R21). Mining is residual (3 BTC in Q2 2026); 10-year take-or-pay colocation MSA with Cerebras (signed 2026-05-04) and first AI revenue $1.08m in Q2 2026 → clear DC/AI candidate.', 'NeoCloudz GPU-as-a-Service revenue from May 2026 (SubQ AI 24-month rental); Cerebras 40 MW MSA; ARMS 200 Tier III pod operating.', 'S029', '2026-07-07', _v10r['DGXX']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30', former_identifiers='Digihost Technology Inc. / DGHI', former_tickers='DGHI'),
 R('DMGI', 'DMG Blockchain Solutions Inc.', 'PENDING_DC_AI', 'PENDING_DMGI', 'S5', 'CONTRACTED', 'HYBRID_MINING', 'As MARA (rule R21). Self-mining remains the core activity (C$6.2m of C$6.4m Q3 FY2026 revenue); only a small signed prefab colocation contract plus a non-binding 50 MW LOI.', 'First commercial two-year prefab colocation contract for an AI client (2026-06-17); Christina Lake 50 MW AI conversion under non-binding LOI; 1.47 EH/s operating, 379 BTC (91% pledged).', 'S030', '2026-06-17', _v10r['DMGI']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
 R('AGMH', 'AGM Group Holdings Inc.', 'PENDING_DC_AI', 'PENDING_AGMH', 'S4', 'OPERATING', 'ND', 'As MARA (rule R21); alternative route M3/REVIEW if AI-server shipments are not confirmed as the primary product.', 'Mass production and shipments of AI all-flash servers confirmed; mining-ASIC business not evidenced as primary.', 'S032', '2026-09-03', _v10r['AGMH']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
 R('QMLS', 'Qumulus AI Inc.', 'PENDING_DC_AI', 'PENDING_QMLS', 'S4', 'OPERATING', 'ND', 'As MARA (rule R21).', 'Commercial HPC revenue $7.711m disclosed as a separate segment in H1 2026; S4 provisional.', 'S033', '2026-08-28', _v10r['QMLS']['L'], pending_since='2026-10-08', pending_deadline='2026-11-30'),
]

REVIEW = []
_v10rv = {r['A']: r for r in v10['review']}
_rv_en = {
 'NCTY': ('Q2 2026 mining revenue is zero; Antminers sold in August 2026 — H1 revenue does not prove mining at the catalog date.', 'Confirm continuing PoW mining after the fleet sale; FIL/staking not counted.', ''),
 'EBON': ('Historical ASIC brand does not prove current mining or current mining-ASIC sales.', 'Current ASIC shipments / mining revenue; separate fintech and renewable-energy lines.', ''),
 'AIBZ': ('Mining operates, but the commercial status of the GPU pilot and AI leases is unverified.', 'Confirm GPU-pilot customers/revenue or the absence of a qualifying AI contract; not admitted until resolved.', 'Minority stake held by Phoenix Group (PHX) — no group consolidation'),
 'BGDE': ('GPU pilot on a decentralised AI network and a joint mining project; commercial AI status unresolved.', 'Contract or recognized revenue from external AI customers; identify the group owner.', 'Mawson Infrastructure Group / MIGI (renamed; SEC CIK 1218683)'),
}
for t, r in _v10rv.items():
    REVIEW.append(dict(ticker=t, company=r['B'], status='REVIEW', security_key=r['D'], reason=_rv_en[t][0], to_confirm=_rv_en[t][1], former_identifiers=_rv_en[t][2], former_tickers=('MIGI' if t == 'BGDE' else ''), source_id=r['J'], doc_date=r['K'], url=r['L']))

CANDIDATES = [
 dict(ticker='ABTS', company='Abits Group Inc.', exchange='Nasdaq', route='M1 candidate', evidence_needed='Latest 20-F/6-K: BTC production and mining revenue in 2026', priority=3, note=''),
 dict(ticker='SAIH', company='SAIHEAT Limited (ex-SAI.TECH)', exchange='Nasdaq', route='M2 candidate (hosting + heat recovery)', evidence_needed='Hosting revenue and MW in the latest 20-F/6-K', priority=3, note=''),
 dict(ticker='ICG', company='Intchains Group Limited (Goldshell)', exchange='Nasdaq', route='REVIEW / M3', evidence_needed='Current ASIC shipments: H1 2026 revenue RMB 11.1m (−93.7%), new ASIC launch targeted Q4 2026; ETH staking treasury (S061)', priority=2, note='Rule R02 "current shipments" currently not met'),
 dict(ticker='NA', company='Nano Labs Ltd', exchange='Nasdaq', route='REVIEW / M3', evidence_needed='ASIC shipments vs BNB-treasury activity in 2026 filings', priority=3, note=''),
 dict(ticker='BTCM', company='BIT Mining Ltd', exchange='NYSE', route='REVIEW', evidence_needed='Continuing Ohio mining and revenue after the SOL-treasury pivot', priority=3, note=''),
 dict(ticker='GPUS', company='Hyperscale Data, Inc. (Sentinum)', exchange='NYSE American', route='REVIEW', evidence_needed='Michigan site being converted from mining to AI (Sep 2026, S062): confirm remaining production and any AI customer contract', priority=3, note=''),
 dict(ticker='BMNR', company='Bitmine Immersion Technologies', exchange='NYSE American', route='REVIEW', evidence_needed='Residual mining revenue vs ETH-treasury activity', priority=3, note=''),
 dict(ticker='BTOG', company='Bit Origin Ltd', exchange='Nasdaq', route='REVIEW', evidence_needed='Mining activity vs DOGE-treasury pivot', priority=3, note=''),
 dict(ticker='NB2', company='Northern Data AG', exchange='Xetra', route='Identity check', evidence_needed='Peak Mining sale to Bitdeer and the Rumble transaction: confirm listing status and whether any mining remains', priority=3, note=''),
 dict(ticker='BTC', company='Vinanz Limited', exchange='LSE', route='M1 candidate (small)', evidence_needed='Production and revenue in latest interim report', priority=3, note=''),
 dict(ticker='NDA', company='Neptune Digital Assets Corp.', exchange='TSXV', route='REVIEW', evidence_needed='Mining vs staking/treasury revenue split', priority=3, note=''),
 dict(ticker='SGLY', company='Singularity Future Technology Ltd.', exchange='Nasdaq', route='REVIEW', evidence_needed='Confirm any operating mining-equipment or mining activity', priority=3, note=''),
]

# --------------------------------------------------------------------------------------
# DC/AI identity reference 1.2 (111): 84 rows carried from v1.0 (v2 snapshot) + 27 rows added
# to DC/AI 1.2 on 2026-10-10 (typed from the project CSV; classification URL where available).
# --------------------------------------------------------------------------------------
DC_REF = []
for r in v10['dc_reference']:
    DC_REF.append(dict(group_id=r['A'], security_key=r['B'], ticker=r['B'].split(':')[0], name_key=r['C'], company=r['D'], segment=r['E'], owner='DC_AI', composition_date='2026-10-10', classification_url=r['H'], added_in_dc_version='1.0/1.1'))
_new = [
 ('DC085', 'GEV:XNYS', 'gevernova', 'GE Vernova', 'S2', 'https://www.gevernova.com/gas-power/resources/faq/data-centers'),
 ('DC086', 'ENR:XETR', 'siemensenergy', 'Siemens Energy', 'S2', 'https://assets.siemens-energy.com/dam/818d34fa-7279-4652-a213-b2f10078fa26/Siemens_Energy_Eaton_Data_Center_25-06-03-pdf_Original%20file.pdf'),
 ('DC087', 'BE:XNYS', 'bloomenergy', 'Bloom Energy', 'S2', 'https://www.bloomenergy.com/news/oracle-and-bloom-energy-collaborate-to-deliver-power-to-data-centers-at-the-speed-of-ai/'),
 ('DC088', 'MTRS:XSTO', 'muntersgroup', 'Munters Group', 'S2', 'https://www.munters.com/en-gb/news-media/press-releases/2026/munters-completes-expansion-of-data-center-cooling-campus-in-daleville-virginia/'),
 ('DC089', 'EXC:XNAS', 'exelon', 'Exelon', 'S1', 'https://www.sec.gov/Archives/edgar/data/0001109357/000110935726000061/exc-20260506ex992.htm'),
 ('DC090', 'SRE:XNYS', 'sempra', 'Sempra', 'S1', 'https://investor.sempra.com/node/46151'),
 ('DC091', 'XEL:XNAS', 'xcelenergy', 'Xcel Energy', 'S1', 'https://www.sec.gov/Archives/edgar/data/0000072903/000007290326000149/xcelearningsreleaseq22026.htm'),
 ('DC092', 'GLW:XNYS', 'corning', 'Corning', 'S3', 'https://www.sec.gov/Archives/edgar/data/0000024741/000002474126000253/glw-20260728xex99xq22026.htm'),
 ('DC093', 'APH:XNYS', 'amphenol', 'Amphenol', 'S3', 'https://investors.amphenol.com/news-and-events/news-details/2025/Amphenol-Corporation-to-Acquire-Connectivity-and-Cable-Solutions-Business-From-CommScope/default.aspx'),
 ('DC094', 'CLS:XNYS', 'celestica', 'Celestica', 'S3', 'https://www.sec.gov/Archives/edgar/data/1030894/000103089426000011/cls-20251231.htm'),
 ('DC095', 'AAOI:XNAS', 'appliedoptoelectronics', 'Applied Optoelectronics', 'S3', 'https://www.sec.gov/Archives/edgar/data/0001158114/000168316826006055/aaoi_ex9901.htm'),
 ('DC096', 'SNDK:XNAS', 'sandisk', 'Sandisk', 'S4', 'https://www.sec.gov/Archives/edgar/data/0002023554/000162828026057406/sndk-20260703.htm'),
 ('DC097', 'BTDR:XNAS', 'bitdeertechnologies', 'Bitdeer Technologies', 'S4', 'https://www.sec.gov/Archives/edgar/data/0001899123/000121390026086938/ea030131301ex99-1.htm'),
 ('DC098', 'WYFI:XNAS', 'whitefiber', 'WhiteFiber', 'S4', 'https://www.sec.gov/Archives/edgar/data/2042022/000121390026088026/ea0300877-10q_whitefiber.htm'),
 ('DC099', 'GLXY:XNAS', 'galaxydigital', 'Galaxy Digital', 'S5', 'https://investor.galaxy.com/node/11461/pdf'),
 ('DC100', '002837:XSHE', 'shenzhenenvicooltechnology', 'Shenzhen Envicool Technology', 'S2', 'https://static.cninfo.com.cn/finalpage/2026-04-21/1225131812.PDF'),
 ('DC101', '300502:XSHE', 'eoptolinktechnology', 'Eoptolink Technology', 'S3', 'https://www.eoptolink.com/product-solutions/800g'),
 ('DC102', '601138:XSHG', 'foxconnindustrialinternet', 'Foxconn Industrial Internet', 'S4', 'https://static.cninfo.com.cn/finalpage/2026-03-11/1225004416.PDF'),
 ('DC103', '000977:XSHE', 'inspurelectronicinformation', 'Inspur Electronic Information (IEIT Systems)', 'S4', 'https://en.ieisystem.com/product/ai/10954.html'),
 ('DC104', '688256:XSHG', 'cambricontechnologies', 'Cambricon Technologies', 'S4', 'https://www.cambricon.com/index.php?m=content&c=index&a=lists&catid=406'),
 ('DC105', '300442:XSHE', 'rangeintelligentcomputingtechnology', 'Range Intelligent Computing Technology', 'S5', 'https://static.cninfo.com.cn/finalpage/2026-04-10/1225091631.PDF'),
 ('DC106', '3017:XTAI', 'asiavitalcomponents', 'Asia Vital Components', 'S2', 'https://financialfilings.com/filings/avc-3017/annual-report/2026/46360201/'),
 ('DC107', '3231:XTAI', 'wistron', 'Wistron', 'S4', 'https://www.wistron.com/en/Newsroom/2025-08-26'),
 ('DC108', '285A:XTKS', 'kioxiaholdings', 'Kioxia Holdings', 'S4', 'https://www.kioxia.com/en-jp/business/ssd/data-center-ssd.html'),
 ('DC109', '3778:XTKS', 'sakurainternet', 'SAKURA internet', 'S4', 'https://www.sakura.ad.jp/corporate/wp-content/uploads/2026/07/260728-ir_2.pdf'),
 ('DC110', 'ME8U:XSES', 'mapletreeindustrialtrust', 'Mapletree Industrial Trust', 'S5', 'https://links.sgx.com/1.0.0/corporate-announcements/CYUAG4IG4R00RAHL/890022_20260522_Investor%20Presentation%20May%202026.pdf'),
 ('DC111', 'MAQ:XASX', 'macquarietechnologygroup', 'Macquarie Technology Group', 'S5', 'https://announcements.asx.com.au/asxpdf/20260826/pdf/0738k7f9vrp2mb.pdf'),
]
for g, sk, nk, nm, seg, url in _new:
    DC_REF.append(dict(group_id=g, security_key=sk, ticker=sk.split(':')[0], name_key=nk, company=nm, segment=seg, owner='DC_AI', composition_date='2026-10-10', classification_url=url, added_in_dc_version='1.2'))
assert len(DC_REF) == 111

# --------------------------------------------------------------------------------------
# Mining exposure register — one row per economic group with any PoW-mining relation,
# regardless of which catalog owns the group. Ownership stays unique (rule R06).
# --------------------------------------------------------------------------------------
_dcref_cap = {'APLD': (7140.0, '2026-10-07'), 'WYFI': (646.04, '2026-10-07'), 'GLXY': (9010.0, '2026-10-02'), 'IREN': (15630.0, '2026-10-07')}
def reg(group_id, ticker, company, owner, status, segment, relation, mstatus, stage, cost_t=None, nav_t=None, fin=None, **kw):
    """fin = (mining_rev, total_rev, period_label, basis, source_id) when not from the Cost Standard."""
    d = dict(group_id=group_id, ticker=ticker, company=company, owner_catalog=owner, status=status, segment=segment, mining_relation=relation, mining_status=mstatus, ai_hpc_stage=stage,
             btc_mined_q2_2026='ND', mining_revenue='ND', total_revenue='ND', share_period='', share_basis='', mining_share_ttm='ND', ttm_quarters='',
             hashrate_eh_operating='ND', hashrate_eh_installed='ND', power_mw='ND', btc_held='ND', btc_held_date='', price_2026_10_15='ND', shares_basic='ND', ads_ratio=1,
             market_cap_usd_m_input='ND', market_cap_date='', cost_standard_tier='—', nav_coverage='no', source_id='', source_date='', primary_url='', notes='', share_status='ND')
    if cost_t and cost_t in CS:
        c = CS[cost_t]
        d.update(btc_mined_q2_2026=c['btc_mined_q2'], mining_revenue=c['mining_rev_q2'], total_revenue=c['total_rev_q2'], share_period='Q2 2026 (3M)', share_status='VALUE',
                 share_basis='BTC-mining revenue ÷ total revenue (XBRL segment facts; Mining Cost Standard v1.0)',
                 mining_share_ttm=(round(c['ttm_mining_rev'] / c['ttm_total_rev'], 4) if c['ttm_total_rev'] else 'ND'), ttm_quarters=c['ttm_quarters'],
                 hashrate_eh_operating=c['hashrate_avg'] if c['hashrate_avg'] is not None else 'ND', hashrate_eh_installed=c['hashrate_deployed'] if c['hashrate_deployed'] is not None else 'ND',
                 power_mw=c['power_mw'] if c['power_mw'] is not None else 'ND', btc_held=c['btc_held_q2'] if c['btc_held_q2'] is not None else 'ND', btc_held_date='2026-06-30' if c['btc_held_q2'] is not None else '',
                 source_id=_cs_sid.get(cost_t, ''), source_date=c['filing_date'], primary_url=c['url'])
    if nav_t and nav_t in NAV:
        n = NAV[nav_t]
        d['nav_coverage'] = 'yes'
        if n['price_2026_10_15'] is not None and n['shares_basic']:
            d.update(price_2026_10_15=n['price_2026_10_15'], shares_basic=n['shares_basic'], ads_ratio=n['ads_ratio'], market_cap_date='2026-10-15')
        for a, b in [('hashrate_eh_operating', 'hashrate_ehs_operating'), ('hashrate_eh_installed', 'hashrate_ehs_installed')]:
            if d[a] == 'ND' and n.get(b) is not None: d[a] = n[b]
        if d['power_mw'] == 'ND':
            mw = n.get('energized_mw_owned'); mwh = n.get('energized_mw_hosted_third_party')
            if mw is not None: d['power_mw'] = mw + (mwh or 0)
        if n.get('btc_held_latest') is not None and (d['btc_held'] == 'ND' or (n.get('btc_held_date') or '') > (d['btc_held_date'] or '')):
            d['btc_held'] = n['btc_held_latest']; d['btc_held_date'] = n.get('btc_held_date') or ''
        if not d['primary_url']:
            d.update(primary_url=n['filing_url'], source_date=n['filing_date'])
    if fin:
        mr, tr, per, basis, sid, st = fin
        d.update(mining_revenue=mr, total_revenue=tr, share_period=per, share_basis=basis, source_id=sid, share_status=st)
    if ticker in _dcref_cap and d['market_cap_usd_m_input'] == 'ND' and d['price_2026_10_15'] == 'ND':
        d['market_cap_usd_m_input'], d['market_cap_date'] = _dcref_cap[ticker]
    if cost_t and cost_t in CS: d['cost_standard_tier'] = {'MARA': '1', 'RIOT': '1', 'CLSK': '1', 'HIVE': '1', 'IREN': '1', 'CIFR': '1', 'CORZ': '1', 'WULF': '1', 'BTDR': '1', 'CANG': '2', 'ABTC': '2', 'BTBT': '2', 'FUFU': '3', 'KEEL': '3', 'HUT': '3'}[cost_t]
    d.update(kw); return d

REGISTER = []
_fin_by = {f['ticker']: f for f in FIN}
def fin_tuple(t):
    f = _fin_by[t]
    return (f['own_mining'], f['total'], f['period'], 'Own-mining revenue ÷ total revenue (catalog Financials)', f['source_id'], f['status'])
# core
for r in CORE:
    t = r['ticker']; nav_t = 'LMFA' if t == 'PWCM' else t
    cost_t = t if t in CS else None
    kw = {}
    if cost_t is None:
        kw['fin'] = fin_tuple(t)
    if t == 'PWCM': kw['btc_mined_q2_2026'] = 27.9
    if t == 'FUFU': kw['hashrate_eh_installed'] = 3.8; kw['notes'] = 'Operating = 19.4 EH/s under management (2026-09-30); installed = 3.8 EH/s self-owned; the Q2 figure of 15.3 EH/s was managed theoretical capacity.'
    REGISTER.append(reg(r['issuer_id'], t, r['company'], 'MINING', 'CORE', r['segment'], 'PURE_MINING' if r['segment'] == 'M1' and 'diversified' not in r['tags'] else ('MINING_SERVICES' if r['segment'] == 'M2' else ('MINING_EQUIPMENT' if r['segment'] == 'M3' else 'DIVERSIFIED_MINING')),
                        r['mining_status'], r['ai_hpc_stage'], cost_t=cost_t, nav_t=nav_t, **kw))
# DC/AI-owned groups with mining relation + parent/child references
for rt in ROUTING:
    t = rt['ticker']
    if rt['status'] in ('EXISTING_DC_AI', 'PARENT_REFERENCE', 'CONTROLLED_CHILD'):
        kw = {}
        if t == 'APLD': kw['fin'] = (37300000, 258748000, 'Q4 FY2026 (3M, ended 2026-05-31)', 'Mining hosting revenue ÷ GAAP total revenue (DC/AI catalog 1.2 disclosure)', 'S059', 'VALUE')
        if t == 'WYFI': kw['fin'] = (0, 28839000, 'Q2 2026 (3M)', 'WhiteFiber never mined (DC/AI 1.2); 0 ÷ total revenues', 'S059', 'VALUE')
        if t == 'GLXY': kw['fin'] = (0, 8710500000, 'Q2 2026 (3M)', 'Proprietary mining wound down in 2025 (FORMER_MINING, DC/AI 1.2); 0 ÷ revenues and gains from operations (gross basis)', 'S059', 'VALUE')
        REGISTER.append(reg(rt['group_id'], t, rt['company'], 'DC_AI', rt['status'], rt['dc_segment'], rt['mining_relation'], 'ACTIVE' if t not in ('GLXY', 'WYFI', 'BTBT') else ('EXITED' if t == 'GLXY' else ('NP' if t == 'WYFI' else 'WIND_DOWN_ANNOUNCED')), rt['ai_hpc_stage'], cost_t=(t if t in CS else None), nav_t=(t if t in NAV else None), **kw))
    elif rt['status'] == 'PENDING_DC_AI':
        ms = 'RESIDUAL' if t == 'DGXX' else ('ND' if t in ('AGMH', 'QMLS') else 'ACTIVE')
        kw = {}
        if t == 'DMGI': kw['fin'] = (6200000, 6400000, 'Q3 FY2026 (3M ended 2026-06-30), CAD', 'Digital currency mining revenue ÷ total revenue (MD&A, C$, via NAV v1.1)', 'S055', 'VALUE')
        if t == 'DGXX': kw['btc_mined_q2_2026'] = 3; kw['notes'] = 'Residual mining: 3 BTC and $0.16m mining revenue in Q2 2026 (10-Q via NAV v1.1); total revenue not extracted.'
        REGISTER.append(reg(rt['group_id'], t, rt['company'], 'UNASSIGNED', 'PENDING_DC_AI', rt['dc_segment'], rt['mining_relation'], ms, rt['ai_hpc_stage'], cost_t=(t if t in CS else None), nav_t=(t if t in NAV else None), **kw))
assert len({r['ticker'] for r in REGISTER}) == len(REGISTER)
_primary = [r['group_id'] for r in REGISTER if r['status'] not in ('CONTROLLED_CHILD', 'PARENT_REFERENCE')]
assert len(set(_primary)) == len(_primary), 'one primary register row per economic group'

# --------------------------------------------------------------------------------------
# Rules — R01–R20 from v1.0 (English summaries) + R21–R26 introduced in v1.1
# --------------------------------------------------------------------------------------
RULES = [
 ('R01', 'Scope', 'Listed companies with operating PoW mining, mining services or mining equipment businesses. Not metals mining; not the crypto sector at large.', '1.0'),
 ('R02', 'Operating activity', 'Actual production, recognized thematic revenue, current shipments or an operating customer mining service. Treasury and idle ASICs are insufficient.', '1.0'),
 ('R03', 'DC/AI priority', 'A qualifying commercial DC/AI business under the DC/AI catalog methodology takes precedence regardless of the mining revenue share.', '1.0'),
 ('R04', 'AI/HPC admission', 'OPERATING: operating service/shipments/revenue. CONTRACTED: legally binding customer contract. BUILDING requires such a contract.', '1.0'),
 ('R05', 'Plans', 'Land, MoU, LoI, pipeline MW, AI marketing and construction without a customer contract = ANNOUNCED; do not move a group by themselves.', '1.0'),
 ('R06', 'Group', 'One economic group — one catalog and one primary segment. Controlled subsidiaries, ADRs and dual listings do not create members.', '1.0'),
 ('R07', 'Segment M1', 'Own PoW mining. Secondary hosting/energy lines are tags; a former miner without current operations is excluded.', '1.0'),
 ('R08', 'Segment M2', 'Commercial mining hosting, co-mining, cloud mining, rental or sale of hashrate to customers. Cloud mining is not GPU cloud.', '1.0'),
 ('R09', 'Segment M3', 'Mining ASICs, equipment and specialised supply/resale. The primary product defines the segment; one quarter of own mining does not reclassify a manufacturer.', '1.0'),
 ('R10', 'Data statuses', 'VALUE — number from the source; ND — not disclosed; NP — not applicable; NM — ratio not meaningful; REVIEW — conflict. A real 0 differs from ND.', '1.0'),
 ('R11', 'Comparability', 'Same period, currency, perimeter and definition for numerator and denominator. Total revenue cannot be declared 100% mining without a breakdown.', '1.0'),
 ('R12', 'Operating units', 'Own BTC / customer BTC / JV BTC / BTC-equivalent separately. Installed, managed and average EH/s separately; Scrypt not summed with SHA-256.', '1.0'),
 ('R13', 'Power', 'Facility electrical MW, actual load, mining MW, IT MW, contracted and pipeline are different metrics.', '1.0'),
 ('R14', 'BTC balance', 'Own-group BTC only, with date and pledge separately. Total minus disclosed pledge = balance after that pledge, not a guarantee of unencumbered assets.', '1.0'),
 ('R15', 'Release control', 'Before release: uniqueness of group/security, anti-join with DC/AI by security, normalised name and known parent/alias map; unknown control = REVIEW.', '1.0'),
 ('R16', 'Transfer', 'A confirmed transition is executed in one cycle: remove from mining core and add to DC/AI. While DC/AI is not updated — transfer proposal only.', '1.0'),
 ('R17', 'Refresh', 'Financials quarterly; operations on new company releases. Listing events, M&A, spin-offs and commercial AI contracts trigger an unscheduled check.', '1.0'),
 ('R18', 'Market data', 'Market capitalisation is a separate module (price date, shares, ADS ratio, currency); the catalog is not a valuation model. v1.1 carries a 2026-10-15 snapshot for 24 of 34 register groups.', '1.0 → 1.1'),
 ('R19', 'Currency of the base', 'Current-only base, not a point-in-time universe for backtests. Former names serve identity matching only (former_identifiers field).', '1.0 → 1.1'),
 ('R20', 'Coverage limit', 'Initial verified international set; completeness of all listed miners is not claimed. Private miners are outside the core. A Candidates register tracks screening.', '1.0 → 1.1'),
 ('R21', 'Pending transfer time limit', 'A PROPOSE/PENDING_DC_AI status lasts at most one refresh cycle. If the DC/AI catalog has not admitted the group by the next DC/AI refresh date (pending_deadline), the group returns to the mining core with tag AI_PENDING. v1.1: 7 groups pending since 2026-10-08, deadline 2026-11-30.', '1.1'),
 ('R22', 'Mining status', 'mining_status ∈ {ACTIVE, WIND_DOWN_ANNOUNCED, SUSPENDED, RESIDUAL, EXITED}. WIND_DOWN_ANNOUNCED stays in the core only while production is confirmed in the latest reported quarter; zero production or the announced stop date → EXITED → removal (R07).', '1.1'),
 ('R23', 'Hashrate marketplaces', 'Hashpower sold through a marketplace (e.g. NiceHash) from own machines = M1 with tag HASHRATE_MARKETPLACE and BTC_EQ units; hashrate contracts or cloud mining sold to customers = M2.', '1.1'),
 ('R24', 'Listed subsidiary (proposed, not applied)', 'A listed, consolidated subsidiary whose own financials are pure mining (ABTC) could be admitted to the mining core with tag CHILD_OF_DC_AI and a free-float adjustment excluding the parent\'s stake. Deferred to v1.2 for decision; v1.1 keeps R06.', '1.1 (proposal)'),
 ('R25', 'Materiality tiers (informational in v1.1)', 'thematic_share = (own mining + hosting/cloud + ASIC revenue) ÷ total revenue, latest comparable period. CORE ≥ 50%; SIGNIFICANT 20–50%; PERIPHERAL < 20%; ND when no breakdown. Tiers are published but do not change membership in v1.1; proposed entry/hold thresholds 20%/15% from v1.2.', '1.1'),
 ('R26', 'Staleness', 'observation_age_days = release date − document date; STALE flag above 120 days. Stale rows stay in the base with the flag and are prioritised in the next refresh.', '1.1'),
]

VERSION_LOG = [
 ('1.0', '2026-10-08', 'Initial release', '13 groups (M1 7 / M2 4 / M3 2); DC/AI reference v2 (84 groups); 38 sources; Excel + DOCX methodology.'),
 ('1.0 audit', '2026-10-11', 'Build audit', '23 findings (3 blocking): stale DC/AI reference, 7 pending groups in neither catalog, KEEL exit status; coverage gaps (CANG, ~13 candidates); no former-identifier field. See claude/mining-catalog-v1_0-audit-2026-10-11.md.'),
 ('1.1', '2026-10-17', 'Release', 'DC/AI reference re-based on catalog 1.2 (111); routing statuses updated (BTDR, WYFI/BTBT, GLXY); rule R21 time limit on pending transfers; mining_status (R22) with KEEL flagged WIND_DOWN_ANNOUNCED; CANG and PWCM added to the core (15 groups); former_identifiers; materiality tiers (informational); mining exposure register (34 groups) on Cost Standard v1.0 / NAV v1.1 inputs; market-cap snapshot 2026-10-15; candidates register (12); staleness flags; English publication package.'),
]

CHANGE_LOG = [
 ('CORE', 'CANG', 'ADDED', 'Core M1 (MIN014) — 656 BTC Q2 2026, 93.4% mining revenue; primary 6-K (S040).'),
 ('CORE', 'PWCM', 'ADDED', 'Core M1 (MIN015) — ex-LM Funding (LMFA), 27.9 BTC Q2 2026; primary 10-Q (S041).'),
 ('CORE', 'KEEL', 'FLAGGED', 'mining_status = WIND_DOWN_ANNOUNCED (S039/S002); Financials row replaced with XBRL segment values (own mining 25,859k of 30,430k).'),
 ('CORE', 'VIP', 'FLAGGED', 'Financials status → REVIEW (revenue perimeter conflict); average hashrate 0.578 EH/s and 20.8 J/TH added from the 10-Q via NAV v1.1.'),
 ('CORE', 'FUFU', 'UPDATED', 'Cloud mining 24.9m counted in thematic lower bound; Sep-2026 operations (19.4 EH/s managed, 3.8 own, 1,388 BTC).'),
 ('CORE', 'ALL', 'UPDATED', 'former_identifiers / former_tickers, mining_status, materiality_tier, market cap 2026-10-15 (where covered by NAV v1.1), cost-standard tier, staleness flags.'),
 ('ROUTING', 'BTDR', 'STATUS', 'PROPOSE_DC_AI → EXISTING_DC_AI (DC097, admitted to DC/AI 1.2 on 2026-10-10).'),
 ('ROUTING', 'WYFI', 'STATUS', 'CONTROLLED_CHILD → EXISTING_DC_AI (DC098; selected as the group security by DC/AI 1.2).'),
 ('ROUTING', 'BTBT', 'STATUS', 'PROPOSE_DC_AI → PARENT_REFERENCE (DC098); residual mining 32 BTC Q2 2026.'),
 ('ROUTING', 'GLXY', 'ADDED', 'EXISTING_DC_AI (DC099, FORMER_MINING) — new in reference 1.2.'),
 ('ROUTING', 'MARA/RIOT/CLSK/DGXX/DMGI/AGMH/QMLS', 'STATUS', 'PROPOSE_DC_AI → PENDING_DC_AI with pending_since 2026-10-08 and deadline 2026-11-30 (rule R21).'),
 ('REFERENCE', 'DC/AI', 'REBASED', '84 (v2, 2026-10-07) → 111 (1.2, 2026-10-10); anti-join re-run: 0 conflicts for the 15 core groups.'),
 ('REVIEW', 'BGDE', 'UPDATED', 'former identifier Mawson Infrastructure Group / MIGI recorded.'),
 ('CANDIDATES', '12 companies', 'ADDED', 'Screening register with required evidence (audit finding C5); LMFA moved from candidates to core as PWCM.'),
 ('RULES', 'R21–R26', 'ADDED', 'Pending time limit; mining status; hashrate marketplaces; listed-subsidiary proposal; materiality tiers; staleness.'),
 ('SOURCES', 'S039–S062', 'ADDED', '24 new entries (primary filings via Cost/NAV standards; market data; DC/AI snapshot; screening sources).'),
]

def canonical():
    return dict(release=RELEASE, core=CORE, financials=FIN, operations=OPS, pledge=PLEDGE, routing=ROUTING, review=REVIEW, candidates=CANDIDATES,
                register=REGISTER, dc_reference=DC_REF, rules=[dict(rule_id=a, name=b, text=c, version=d) for a, b, c, d in RULES],
                sources=SOURCES, version_log=[dict(version=a, date=b, event=c, details=d) for a, b, c, d in VERSION_LOG],
                change_log=[dict(area=a, item=b, change=c, details=d) for a, b, c, d in CHANGE_LOG])

if __name__ == '__main__':
    import hashlib
    data = canonical()
    s = json.dumps(data, ensure_ascii=False, sort_keys=True, indent=1)
    out = os.path.join(REPRO, 'catalog_data.json')
    open(out, 'w', encoding='utf-8').write(s)
    print('catalog_data.json written:', len(s), 'bytes; sha256', hashlib.sha256(s.encode('utf-8')).hexdigest())
    print({k: len(v) for k, v in data.items() if isinstance(v, list)})
