← Back to Pull requests

[CaOS3] feat(api): 注文・オーダーストップ・レジの状態の変更を DB の通知でインスタンス同士に知らせる #825

Open
unknown opened this pull request with 119 lines diff across 1 files
View on GitHub
unknown unknown commented on Oct 08, 2026 10:29 UTC
Author

概要


Cloud Run のインスタンスが2〜3台になっても、注文・オーダーストップ・レジの状態の変更が、全部の画面に届くようにします。変更を受けた台が DB の通知(pg_notify)で知らせ、ほかの台が待ち受け(LISTEN)で受けて DB から読み直し、自分の画面へ配ります。

CaOS の列の作り直し(その2)で、#793 の中身(#795 を取り込む前の3コミット)をそのまま CaOS2(#815)の上に置き直したものです。設計の比べ(1台に固定する案との比較)と、このままにすると決めた理由は #793 のコメントにあります。本番の Cloud Run(上限 20 台)は、祭の前でも同じリビジョンで 2〜3 台になっている時間がよくありました。

中身


  • api/internal/handlers/order_listener.go:1本の接続で orders_changed・master_state_changed・cashier_state_changed を LISTEN。自分の通知は無視し、重なった通知はまとめ、待ち受けを始めたら全部を配り直す。接続は定期的に確かめて張り直す

  • 注文・オーダーストップ・レジの状態を書いたときに通知を送る

  • DATABASE_LISTEN_URL:LISTEN はプーラー経由では届かないので、プーラーを通らない接続文字列を渡す(無ければ DATABASE_URL)。プレビューでは CI が Neon の直の接続文字列を渡す
  • マージのあとに要ること


  • 本番の Cloud Run に DATABASE_LISTEN_URL を Secret Manager から渡す(忘れても API は動くが、別の台につながった画面に変更が届かない)
  • 確かめたこと


  • #793 と同じ中身(+778 行)。go build・go vet・go test(DB のテストは LISTEN_TEST_DATABASE_URL があるとき)
  • 🤖 Generated with Claude Code

    Diff: 119 lines (+89 / -30) across 1 files Reviewer: claude[bot] Review duration: 16m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 119 lines diff across 1 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.286
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #825"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.5% · Safe to merge
    19.5%