Files
awoooi/apps/api/migrations/adr094_hermes_dispatch_log.sql
Your Name 00443370ba
Some checks failed
run-migration / migrate (push) Failing after 16s
CD Pipeline / build-and-deploy (push) Has been cancelled
feat(ws6): Hermes observability — latency logging + dispatch audit table
- nl_gateway.py: time.monotonic() 測量 SDK call 耗時
  hermes_nl_dispatch log 加 latency_ms + success 欄位
- migrations/adr094_hermes_dispatch_log.sql
  hermes_dispatch_log(bigserial + chat_id/user_id/agent/latency_ms/success)
  已部署至 prod awoooi_prod
  ADR-094 P95 latency 監控 + 幻覺追蹤用

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 02:10:06 +08:00

27 lines
1.2 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ADR-094: Hermes NL Dispatch Audit Log
-- 每次 @mention 觸發 → 記錄派發決策供 P95 latency 監控與幻覺追蹤
-- 2026-04-25 ogt + Claude Sonnet 4.6
CREATE TABLE IF NOT EXISTS hermes_dispatch_log (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
chat_id VARCHAR(32) NOT NULL,
user_id BIGINT NOT NULL,
username VARCHAR(100),
agent_name VARCHAR(64) NOT NULL,
input_preview VARCHAR(200), -- 前 200 字,不存完整輸入(隱私)
latency_ms INTEGER,
success BOOLEAN NOT NULL DEFAULT TRUE,
error_type VARCHAR(64),
budget_usd NUMERIC(8, 5)
);
CREATE INDEX IF NOT EXISTS idx_hermes_dispatch_created ON hermes_dispatch_log(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_hermes_dispatch_agent ON hermes_dispatch_log(agent_name);
CREATE INDEX IF NOT EXISTS idx_hermes_dispatch_user ON hermes_dispatch_log(user_id);
GRANT SELECT, INSERT ON hermes_dispatch_log TO awoooi;
GRANT USAGE, SELECT ON SEQUENCE hermes_dispatch_log_id_seq TO awoooi;
COMMENT ON TABLE hermes_dispatch_log IS 'ADR-094: Hermes NL 派發審計日誌P95 latency 監控 + 幻覺追蹤)';