load_loop_state (loop_guard.py)

JIGGA ยท infra

Step 1: โ†’ step 2 tool: step 1. terse " no step 1: step 2 steps: no nodes? step 1, step 2, step 3? null?** Actually terse per instructions. Output: "Loads persisted loop-guard state from disk, restoring wake counters and rate-limit timestamps for cron scheduling." (20 words)

# Source: https://github.com/JIGGAI/JIGGA | License: MIT | Copyright 2026 JIGG AI
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Any

from jigga.core.io import read_json, write_json

WAKE_WINDOW = timedelta(hours=1)


def _state_path(home: Path) -> Path:
    return home / "loop_state.json"


def load_loop_state(home: Path) -> dict[str, Any]:
    path = _state_path(home)
    if not path.exists():
        return {"wakes": {}, "cron_fired": {}}
    data = read_json(path)
    data.setdefault("wakes", {})
    data.setdefault("cron_fired", {})
    return data


def save_loop_state(home: Path, state: dict[str, Any]) -> None:
    write_json(_state_path

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key