SPB Git

spb/modelmap Public License

Internal cartography of local LLMs on Apple Silicon — registered, gated, negative-first. Public atlas at modelmap.io.

Python 66.3% JavaScript 24.5% CSS 8.1% Shell 0.7%
3.1 KB · 90 lines python
Raw Blame History
1#!/usr/bin/env python32# =============================================================================3#  Project   : modelmap4#  File      : tools/publish.py5#  Purpose   : Export validated atlas entries to site/data — refuses incomplete6#  Author    : Simon-Pierre Boucher7#  Contact   : contact@spboucher.ai8#  Website   : https://modelmap.io9#  Created   : 2026-08-1210#  Modified  : 2026-08-1211#  Platform  : macOS / Apple Silicon (arm64)12#  License   : All rights reserved (research code)13# =============================================================================14"""Publish gate for the atlas (charter §14 hard constraints).1516Walks atlas/<model>/<type>/<version>/, validates each entry's mapcard.json17(schema v0) plus the presence of provenance.json and confidence.md, and exports18valid entries to site/data/atlas-index.json. Any violation blocks that entry19and is reported; nothing incomplete ever reaches modelmap.io.20"""2122from __future__ import annotations2324import json25import sys26from pathlib import Path2728ROOT = Path(__file__).resolve().parent.parent29sys.path.insert(0, str(ROOT / "src"))3031from modelmap.atlas.mapcard import MapCard323334def entries():35    atlas = ROOT / "atlas"36    for model in sorted(p for p in atlas.iterdir() if p.is_dir()):37        for map_type in sorted(p for p in model.iterdir() if p.is_dir()):38            yield from sorted(p for p in map_type.iterdir() if p.is_dir())394041def main() -> int:42    exported, blocked = [], []43    for entry in entries():44        rel = entry.relative_to(ROOT)45        problems = []46        for required in ("provenance.json", "confidence.md", "mapcard.json"):47            if not (entry / required).exists():48                problems.append(f"missing {required}")49        card = None50        if not problems:51            try:52                card = MapCard.load(entry / "mapcard.json")53                problems += card.validate()54            except (json.JSONDecodeError, TypeError) as e:55                problems.append(f"mapcard.json unreadable: {e}")56        if problems:57            blocked.append((str(rel), problems))58        else:59            exported.append({60                "path": str(rel),61                "map_id": card.map_id,62                "map_type": card.map_type,63                "model_id": card.model_id,64                "quantization": card.quantization,65                "confidence_level": card.confidence_level,66                "replication_rate": card.replication_rate,67                "negative_result": card.negative_result,68                "created": card.created,69            })7071    out = ROOT / "site" / "data"72    out.mkdir(parents=True, exist_ok=True)73    (out / "atlas-index.json").write_text(json.dumps({74        "author": "Simon-Pierre Boucher",75        "contact": "contact@spboucher.ai",76        "website": "https://modelmap.io",77        "entries": exported,78    }, indent=2) + "\n")7980    print(f"publish: {len(exported)} entry(ies) exported to site/data/atlas-index.json")81    for rel, problems in blocked:82        print(f"BLOCKED {rel}:")83        for p in problems:84            print(f"  - {p}")85    return 1 if blocked else 0868788if __name__ == "__main__":89    sys.exit(main())90