memoria/scripts/config.py
agent-admin 86c7dc9ded config: default timezone → America/Indiana/Indianapolis
Deployment is in Fort Wayne, IN (Eastern — most of central/eastern
Indiana uses America/Indiana/Indianapolis). Upstream defaulted to
America/Chicago which would have caused staleness-gate and daily-log
date rollover to fire an hour off from local wall-clock.

Override still available via MEMORIA_TZ env var for other deployments.
Unknown zone behaviour unchanged (warn + fall back to system local).

FORK.md env-var table + divergences section updated to match.
2026-04-24 17:56:32 -04:00

57 lines
2.3 KiB
Python

"""Path constants and configuration for the personal knowledge base."""
import os
from pathlib import Path
from datetime import datetime, timezone
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
# ── Paths ──────────────────────────────────────────────────────────────
ROOT_DIR = Path(__file__).resolve().parent.parent
DAILY_DIR = ROOT_DIR / "daily"
KNOWLEDGE_DIR = ROOT_DIR / "knowledge"
CONCEPTS_DIR = KNOWLEDGE_DIR / "concepts"
CONNECTIONS_DIR = KNOWLEDGE_DIR / "connections"
QA_DIR = KNOWLEDGE_DIR / "qa"
REPORTS_DIR = ROOT_DIR / "reports"
SCRIPTS_DIR = ROOT_DIR / "scripts"
HOOKS_DIR = ROOT_DIR / "hooks"
AGENTS_FILE = ROOT_DIR / "AGENTS.md"
INDEX_FILE = KNOWLEDGE_DIR / "index.md"
LOG_FILE = KNOWLEDGE_DIR / "log.md"
STATE_FILE = SCRIPTS_DIR / "state.json"
# ── Timezone ───────────────────────────────────────────────────────────
# Configurable via the MEMORIA_TZ environment variable. Default is
# America/Indiana/Indianapolis (Eastern — covers Fort Wayne and most of
# central/eastern Indiana). Upstream defaulted to America/Chicago; we
# diverge to match our actual deployment. If the zone name is unknown
# (missing tzdata, typo), log a warning and fall back to the system local
# timezone via astimezone() with no argument.
TIMEZONE = os.environ.get("MEMORIA_TZ", "America/Indiana/Indianapolis")
try:
TZ: ZoneInfo | None = ZoneInfo(TIMEZONE)
except ZoneInfoNotFoundError:
import logging
logging.getLogger(__name__).warning(
"Timezone %r not found; falling back to system local time.", TIMEZONE
)
TZ = None
def _now_local() -> datetime:
"""Current datetime in the configured TIMEZONE (or system local as fallback)."""
if TZ is not None:
return datetime.now(TZ)
return datetime.now(timezone.utc).astimezone()
def now_iso() -> str:
"""Current time in ISO 8601 format, in the configured TIMEZONE."""
return _now_local().isoformat(timespec="seconds")
def today_iso() -> str:
"""Current date in ISO 8601 format, in the configured TIMEZONE."""
return _now_local().strftime("%Y-%m-%d")