import json, time, os

STATE="/sovereign/unbound270/runtime/kingkong_state.json"

def load_state():
    try:
        with open(STATE) as f:
            return json.load(f)
    except:
        return None

def should_latch(now):
    s = load_state()
    if not s: return None
    if s["latched_at"] == 0: return None
    if now < s["latched_at"] + s["hold_seconds"]:
        return s
    return None
