feat: waterway diamonds, cable corridor zones, cache resilience

- Render 9 strategic waterway chokepoints as cyan diamond markers
  (Hormuz, Malacca, Suez, Panama, Bab-el-Mandeb, Taiwan, Gibraltar,
  GIUK Gap, Bosphorus) with throughput tooltips
- Render 6 submarine cable corridors as dashed blue rectangles
  (transatlantic N/S, transpacific, asia-europe, red sea, med)
- Add waterways + cable_corridors to /api/static and SSE payloads
- Make cache.set() and evict_expired() swallow sqlite3 write errors
  instead of crashing callers (fixes "readonly database" in dashboard)
- Infrastructure layer: 134 → 173 items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Marc Shade
2026-02-24 10:37:03 -05:00
co-authored by Claude Opus 4.6
parent 95b149ad55
commit 71fbb1cda4
3 changed files with 76 additions and 15 deletions
+23 -12
View File
@@ -70,14 +70,21 @@ class Cache:
return json.loads(row[0])
def set(self, key: str, value: Any, ttl_seconds: int) -> None:
"""Store a value with TTL in seconds."""
conn = self._get_conn()
now = time.time()
conn.execute(
"INSERT OR REPLACE INTO cache (key, value, expires_at, created_at) VALUES (?, ?, ?, ?)",
(key, json.dumps(value, default=str), now + ttl_seconds, now),
)
conn.commit()
"""Store a value with TTL in seconds.
Write failures (readonly DB, locked) are logged and swallowed —
the cache is best-effort and must never crash the caller.
"""
try:
conn = self._get_conn()
now = time.time()
conn.execute(
"INSERT OR REPLACE INTO cache (key, value, expires_at, created_at) VALUES (?, ?, ?, ?)",
(key, json.dumps(value, default=str), now + ttl_seconds, now),
)
conn.commit()
except sqlite3.OperationalError as exc:
logger.warning("Cache write failed for %s: %s", key, exc)
def delete(self, key: str) -> None:
"""Delete a specific key."""
@@ -87,10 +94,14 @@ class Cache:
def evict_expired(self) -> int:
"""Remove all expired entries. Returns count removed."""
conn = self._get_conn()
cursor = conn.execute("DELETE FROM cache WHERE expires_at < ?", (time.time(),))
conn.commit()
return cursor.rowcount
try:
conn = self._get_conn()
cursor = conn.execute("DELETE FROM cache WHERE expires_at < ?", (time.time(),))
conn.commit()
return cursor.rowcount
except sqlite3.OperationalError as exc:
logger.warning("Cache evict failed: %s", exc)
return 0
def stats(self) -> dict[str, Any]:
"""Cache statistics."""