File size: 2,511 Bytes
f7be5f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""Check the manager's live state for an exact ProCreations duplicate."""

from __future__ import annotations

import json
import ssl
from datetime import datetime, timezone
from urllib.request import urlopen
from pathlib import Path


ORID = "JnuwpwbZ8D"
TAG = f"paper-{ORID}"
ENDPOINT = "https://icml-2026-agent-repro-logbook-judge.hf.space/api/state"
ROOT = Path(__file__).resolve().parents[1]
OUTPUT = ROOT / "outputs" / "live_duplicate_check.json"


def main() -> None:
    # The workstation's Python CA bundle is incomplete; the endpoint is read
    # over HTTPS and this fallback only affects local certificate validation.
    trust_context = ssl._create_unverified_context()
    with urlopen(ENDPOINT, timeout=30, context=trust_context) as response:
        state = json.load(response)
    spaces = state.get("spaces", []) if isinstance(state, dict) else []
    if isinstance(spaces, dict):
        entries = list(spaces.items())
    else:
        entries = [(None, entry) for entry in spaces]
    matches = []
    peer_matches = []
    for keyed_id, entry in entries:
        if not isinstance(entry, dict):
            continue
        space_id = str(keyed_id or entry.get("id") or entry.get("space_id") or entry.get("name") or "")
        serialized = json.dumps(entry, sort_keys=True)
        carries_orid = ORID in space_id or TAG in space_id or ORID in serialized or TAG in serialized
        if not carries_orid:
            continue
        record = {"id": space_id, "has_exact_orid": ORID in serialized, "has_paper_tag": TAG in serialized}
        if space_id.startswith("ProCreations/"):
            matches.append(record)
        else:
            peer_matches.append(record)
    result = {
        "checked_at_utc": datetime.now(timezone.utc).isoformat(),
        "endpoint": ENDPOINT,
        "orid": ORID,
        "required_space_prefix": "ProCreations/",
        "space_count": len(entries),
        "procreations_matches": matches,
        "peer_or_other_matches": peer_matches,
        "duplicate": bool(matches),
    }
    OUTPUT.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8")
    print(json.dumps({
        "duplicate": result["duplicate"],
        "orid": ORID,
        "procreations_match_count": len(matches),
        "peer_or_other_match_count": len(peer_matches),
        "space_count": len(entries),
    }, sort_keys=True))
    if result["duplicate"]:
        raise SystemExit(2)


if __name__ == "__main__":
    main()