Skip to content

Commit e8f8439

Browse files
committed
enrich proxy messages from claude transcripts
1 parent 4ce819d commit e8f8439

10 files changed

Lines changed: 565 additions & 29 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ Recorded LLM proxy traffic is exposed as a single logical dataset, `proxy_messag
324324

325325
Rows are globally deduplicated by `message_id` — a 16-character hex prefix of `sha256(conversation_id : role : canonicalJson(content))`. Identical content in the same conversation always produces the same id, so the user-history blocks that Anthropic replays on every request are written once. The walker also tracks `previous_message_id` across exchanges so callers can reconstruct conversation order even after dedup.
326326

327-
`conversation_id` is resolved tiered — Claude Code's `metadata.user_id.session_id` when present, otherwise a stable 16-hex hash of the first user message's content, otherwise a hash of `exchange_id` (so even single-shot malformed exchanges get a deterministic id). `conversation_source` is `claude_code` when the recorded user-agent starts with `claude-cli/`, else `api`. When Claude Code is configured through `ctvs attach`, a local hook records `cwd` and `git_branch` into the proxy JSONL so those fields survive Gateway/Central server shipping; local query/export also falls back to Claude Code transcript metadata when available.
327+
`conversation_id` is resolved tiered — Claude Code's `metadata.user_id.session_id` when present, otherwise a stable 16-hex hash of the first user message's content, otherwise a hash of `exchange_id` (so even single-shot malformed exchanges get a deterministic id). `conversation_source` is `claude_code` when the recorded user-agent starts with `claude-cli/`, else `api`. When Claude Code is configured through `ctvs attach`, a local hook records `cwd` and `git_branch` into the proxy JSONL so those fields survive Gateway/Central server shipping; local query/export also scans Claude Code transcripts to enrich matching rows with JSONL metadata such as `provider_uuid`, `parent_uuid`, `request_id`, `entrypoint`, `client_version`, and `user_type`.
328328

329-
JSON columns (`attributes`, `status`, `tools`, `tool_args`) carry sparse structured data; scalars are accessed with `JSON_VALUE(<col>, '$.path')`. `attributes` holds request settings, per-message `usage` (assistant only), `timing.latency_ms`, and `client.claude_version` when available; `status` holds `tool_status` on tool results, `finish_reason` on the last assistant part, and `error_code` / `error_message` on error parts.
329+
JSON columns (`attributes`, `status`, `tools`, `tool_args`, `compact_metadata`, `raw_frame`) carry sparse structured data; scalars are accessed with `JSON_VALUE(<col>, '$.path')`. `attributes` holds request settings, per-message `usage` (assistant only), `timing.latency_ms`, and `client.claude_version` when available; `status` holds `tool_status` on tool results, `finish_reason` on the last assistant part, and `error_code` / `error_message` on error parts.
330330

331331
For the full per-column derivation table see [skills/collectivus-query/references/query-cli.md](skills/collectivus-query/references/query-cli.md).
332332

skills/collectivus-query/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ Key columns:
5757
- `role``system`, `user`, `assistant`, or `tool`.
5858
- `part_type``text`, `reasoning`, `tool_call`, `tool_result`, `image`, `file`, `error`, or a passed-through provider type.
5959
- `cwd`, `git_branch` — Claude Code local context when available from transcript metadata or the Collectivus attach hook.
60+
- `provider_uuid`, `parent_uuid`, `request_id`, `entrypoint`, `client_version`, `user_type` — Claude Code JSONL metadata when local transcript rows can be matched to proxy messages.
6061
- `content_text` — extracted text payload for text / reasoning / tool_result / error parts; null otherwise.
6162
- `tool_name`, `tool_call_id`, `tool_args` — populated on `tool_call` parts; `tool_result` parts carry the matching `tool_call_id` and a `status.tool_status` of `success` or `error`.
6263
- `attributes` (JSON) — request settings, per-message `usage` (assistant only), exchange-level `timing`, and `client.claude_version` when available.
6364
- `status` (JSON) — sparse; carries `finish_reason` on the last assistant part, `tool_status` on tool results, and `error_code` / `error_message` on error parts.
6465

65-
Run `ctvs query schema proxy_messages --format markdown` for the full 26-column reference (plus `gateway_id` and `date` partition columns).
66+
Run `ctvs query schema proxy_messages --format markdown` for the authoritative column reference.
6667

6768
## Example SQL
6869

0 commit comments

Comments
 (0)