fix(proxy): add stable usage keys and idempotent raw-response logging

Derive request ids from upstream envelope ids (Codex/OpenAI top-level
id, Gemini responseId, Claude message id with non-empty filtering)
scoped as session:{app_type}:{provider_id}:{id} for non-Claude sources;
Claude keeps bare session:{id} to preserve session-log convergence.

The logger now queries and conditionally writes under a single
connection guard: identical semantic replays return without writing or
notifying, session_log rows may be upgraded by proxy, and same-id
different-semantic responses land on a deterministic SHA-256 collision
fallback key instead of being overwritten. Fixes the random-UUID
INSERT OR REPLACE duplication behind #5496.
This commit is contained in:
Jason
2026-07-20 12:16:57 +08:00
parent df3e07edbb
commit c9ac6efd69
5 changed files with 385 additions and 54 deletions
+1 -1
View File
@@ -1181,7 +1181,7 @@ mod tests {
Some("chatcmpl-claude-compatible")
);
assert_eq!(
usage.dedup_request_id(),
usage.dedup_request_id(None),
"session:chatcmpl-claude-compatible"
);
}