Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed GazetteCache

From Leeroopedia
Knowledge Sources
Domains Persistence, Caching
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete file-based gazette cache that stores generated gazette results as timestamped JSON files per run, with listing, retrieval, and legacy migration support.

Description

The GazetteCache module (`gazette/cache.py`) stores gazette results in `~/.worldseed/runs/{run_id}/gazettes/{gazette_id}.json`. The `gazette_id` is timestamp-based (`YYYYMMDD_HHMMSS`), providing natural newest-first ordering.

Functions:

  • save: Writes a `GazetteResult` as JSON, returns the gazette_id
  • get_gazette: Reads a specific gazette by ID, deserializes to `GazetteResult`
  • list_gazettes: Lists all gazettes for a run (summary only), sorted newest-first
  • get_latest: Reads the most recent gazette
  • _migrate_legacy: Auto-migrates old single `gazette.json` to the `gazettes/` directory

Usage

Import these functions to cache and retrieve gazette results. Called by the gazette API route handler.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/gazette/cache.py

Signature

def save(run_id: str, result: GazetteResult) -> str: ...
def get_gazette(run_id: str, gazette_id: str) -> GazetteResult | None: ...
def list_gazettes(run_id: str) -> list[dict[str, Any]]: ...
def get_latest(run_id: str) -> GazetteResult | None: ...

Import

from worldseed.gazette.cache import save, get_gazette, list_gazettes, get_latest

Usage Examples

from worldseed.gazette.cache import save, list_gazettes, get_gazette

# Save a generated gazette
gazette_id = save("run_001", gazette_result)
print(f"Saved as {gazette_id}")

# List all gazettes
gazettes = list_gazettes("run_001")
for g in gazettes:
    print(f"{g['id']}: {g['edition_title']}")

# Retrieve a specific gazette
result = get_gazette("run_001", "20260325_014530")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment