* add staging ios app build script * feat(api): add OpenTelemetry LGTM stack for local observability Wire OTel traces, metrics, and logs through a collector to Tempo, Prometheus, and Loki, with custom LLM instrumentation, dev compose overlay, Grafana provisioning, env templates, and development.sh auto-start. Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expand observability, harden dev tooling, and fix expo staging UX Add business and LLM Prometheus metrics with Grafana dashboards, alerting, and a metrics verification script. Wire telemetry through adapters and core LLM paths, and document the local LGTM workflow. Fix development.sh for macOS bash 3.2, open Grafana and eval-web in Chrome, and repair eval-web auto-open (unbound EVAL_WEB_BROWSER_SCHEDULED). Merge internal-eval into the main dev script with improved compose handling. Require EXPO_PUBLIC_* at build time, improve iOS HTTP ATS for staging IPs, show memoir empty state instead of load errors when no chapters exist, and add jest env setup plus chapter list response normalization. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: enable Grafana Assistant Cursor plugin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: memoir empty state and repair withdrawn 0020_chapters_book_id stamp Show empty memoir UI when the chapter list succeeds with no items; treat auth/404 as non-fatal. Extend alembic revision repair so local dev DBs stamped with the removed 0020_chapters_book_id migration can roll back and upgrade to 0019. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Kevin <kevin@brighteng.org> Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""修复已撤回 migration 写入的 alembic_version(跨环境一次性兼容)。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from sqlalchemy import Connection, text
|
||
|
||
_WITHDRAWN_0020_REVISIONS = frozenset(
|
||
{
|
||
"0020_add_tts_audio_urls_column",
|
||
"0020_backfill_missing_schema",
|
||
"0020_backfill_all_missing_columns",
|
||
# 曾本地试运行后从仓库撤回,仅 dev 库可能残留 stamp
|
||
"0020_chapters_book_id",
|
||
}
|
||
)
|
||
_REPAIR_TARGET_REVISION = "0018_users_language_preference"
|
||
|
||
|
||
def try_repair_withdrawn_0020_revision(conn: Connection) -> bool:
|
||
"""
|
||
若当前 stamp 为已撤回的 0020_*,回退到 0018 以便重新执行 0019_align_legacy_schema。
|
||
|
||
返回 True 表示已执行 UPDATE;调用方负责 commit。
|
||
"""
|
||
row = conn.execute(text("SELECT version_num FROM alembic_version")).fetchone()
|
||
if row is None:
|
||
return False
|
||
current = row[0]
|
||
if current not in _WITHDRAWN_0020_REVISIONS:
|
||
return False
|
||
conn.execute(
|
||
text("UPDATE alembic_version SET version_num = :target"),
|
||
{"target": _REPAIR_TARGET_REVISION},
|
||
)
|
||
return True
|