Daily Art: Codex guardrails (atomic image, attribution/license, blocked lever)
Hardening before it runs further on the cycle: - DB-lock/network: all HTTP (metadata + image) happens before any write; the write txn opens only at the brief INSERT and commits immediately. Images download to a temp file then atomic os.replace into cache (a reader never sees a half-written file). - Site-timezone "daily" already used local_today() (same rhythm as the Brief) — confirmed. - Attribution from day one: store + return title/artist/date/medium/department/credit/ source_url/object_id/source + museum name + is_public_domain license marker + the full- res source URL (for a richer /art view later). UI can show: Title · Artist · The Met. - "highlight != always beautiful": added a manual `blocked` flag on art_pool (excluded from picks) as the cheap curation lever; a featured override can follow. Schema migrated (existing art tables get the new columns). 373 tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,7 +49,17 @@ def test_pick_caches_image_metadata_and_marks_shown(conn):
|
||||
a = art.pick_daily(conn, art_date="2026-06-21")
|
||||
assert a and a["object_id"] in (1, 3) and a["title"] in ("Sunflowers", "Irises")
|
||||
assert a["artist"] == "Van Gogh" and a["image_file"]
|
||||
assert a["is_public_domain"] == 1 # license marker stored
|
||||
assert list(art.cache_dir().glob(f"{a['object_id']}.*")) # image cached locally
|
||||
assert not list(art.cache_dir().glob("*.tmp")) # atomic write left no temp file
|
||||
|
||||
|
||||
def test_blocked_pieces_are_never_picked(conn):
|
||||
art.harvest_pool(conn)
|
||||
conn.execute("UPDATE art_pool SET blocked=1 WHERE object_id=1") # block the good one
|
||||
conn.commit()
|
||||
a = art.pick_daily(conn, art_date="2026-06-21")
|
||||
assert a is None or a["object_id"] != 1 # never the blocked piece
|
||||
shown = conn.execute("SELECT shown_at FROM art_pool WHERE object_id=?", (a["object_id"],)).fetchone()[0]
|
||||
assert shown == "2026-06-21"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user