"""Persistent backend package for the IMDb offline clone (stage: backend). Owns runtime configuration for the persistent full-stack candidate: the SQLite data directory (always outside the candidate clone/ tree), the frozen clock, and the isolated admin/reset boundary. Public authentication uses the vendored ``websitebench.site_backend`` integration seam. Nothing in this package ever contacts IMDb or its GraphQL API; all state is local fixture state and dated source aggregates are never mutated by local actions. """ from __future__ import annotations import os from pathlib import Path SITE_ID = "imdb" STAGE = "backend" # Stable task 901–905 runtime identity; current completion evidence is carried # by the WebsiteBench manifest and artifact hashes rather than renaming it. VERSION = "imdb-r3-backend-2026-07-25.1" FIXTURE_ID = "imdb-v2-901-905-r2" FROZEN_CLOCK = "2026-07-25T12:00:00-04:00" CAPTURE_DATE = "2026-07-25" ASSETS_BASE = "/static/assets/source-current/2026-07-25" CATALOG_ASSETS_BASE = "/static/assets/source-current/2026-08-10" SESSION_COOKIE = "clawbench_imdb_session" # tasks 901–905 compatibility alias PRIMARY_SESSION_COOKIE = "__Host-websitebench-imdb-session" CSRF_VALUE = "imdb-r2-public-fixture" DEFAULT_ADMIN_TOKEN = "imdb-admin-dev-token" ADMIN_TOKEN_HEADER = "X-WebsiteBench-Admin-Token" LEGACY_ADMIN_TOKEN_HEADER = "X-Clawbench-Admin-Token" DEFAULT_PORT = 8457 SEED_AUTH_ACCOUNTS = ( { "subject_id": "alex", "email": "alex.green@example.test", "display_name": "Alex Green", "password": os.environ.get( "WEBSITEBENCH_EVALUATOR_PRIMARY_SECRET", "Alex-local-2026!" ), }, { "subject_id": "jordan", "email": "jordan.lee@example.test", "display_name": "Jordan Lee", "password": os.environ.get( "WEBSITEBENCH_EVALUATOR_SECONDARY_SECRET", "Jordan-local-2026!" ), }, ) # materials//clone/backend/__init__.py -> materials/ SITE_DIR = Path(__file__).resolve().parents[2] LOCAL_RATING_DISCLOSURE = ( "Local rating \u2014 never affects real IMDb aggregates" ) def data_dir() -> Path: """Resolve the persistent data directory (env-overridable, lazy). Defaults to materials/imdb/data, which is intentionally outside the candidate root clone/ so verification fingerprints never include runtime state. """ override = ( os.environ.get("WEBSITEBENCH_DATA_DIR", "").strip() or os.environ.get("CLAWBENCH_DATA_DIR", "").strip() ) if override: return Path(override) return SITE_DIR / "data" def db_path() -> Path: return data_dir() / "imdb.sqlite3" def admin_token() -> str: return ( os.environ.get("WEBSITEBENCH_ADMIN_TOKEN", "").strip() or os.environ.get("CLAWBENCH_ADMIN_TOKEN", "").strip() or ( DEFAULT_ADMIN_TOKEN ) )