Skip to content

feat: per-turn trace registry + weave-claude-plugin trace commands#57

Draft
rgao-coreweave wants to merge 1 commit into
mainfrom
feat/trace-id-per-turn-registry
Draft

feat: per-turn trace registry + weave-claude-plugin trace commands#57
rgao-coreweave wants to merge 1 commit into
mainfrom
feat/trace-id-per-turn-registry

Conversation

@rgao-coreweave
Copy link
Copy Markdown
Contributor

Summary

  • New src/traceRegistry.ts: append-only JSON file at ~/.weave_claude_plugin/trace-registry.json with one entry per turn (session_id, turn_number, trace_id, conversation_id, started_at, ended_at, tool_count, subagent_count, cwd). Bounded at 1000 entries, FIFO eviction, atomic-ish writes via rename.
  • recordTurn(...) wired into handleStop immediately after the turn span ends. Best-effort — silent on I/O errors.
  • New CLI surface: weave-claude-plugin trace recent [--limit N], weave-claude-plugin trace lookup --session <id>, weave-claude-plugin trace lookup --trace <prefix>.

Why

After the May-14 drop session span, flatten subagents refactor, every turn is its own root trace, but the daemon doesn't surface its trace_id anywhere a user can see by default (the DEBUG-level Stop log stamps it but DEBUG is off). When a user reports "Weave isn't showing X for the turn I just had," the first ask is always "give me the trace_id" — and without one the only recourse is full-corpus query filtering.

Test plan

  • node scripts/smoke/verify-trace-registry.mjs — runs the daemon end-to-end with HOME redirected to a tmp dir, drives 3 turns across 2 sessions, asserts file written, entries recorded, recentTurns ordering, per-session filter, trace-prefix resolver, cwd capture, schema-version pinning. 11/11 checks pass.
  • weave-claude-plugin trace --help and trace recent smoke-tested locally.
  • HOME-redirect safety guard in the test prevents clobbering the real registry.
  • npm run build clean.

🤖 Generated with Claude Code

After the May-14 `drop session span, flatten subagents` refactor, every
turn is its own root trace, but the daemon doesn't surface its trace_id
anywhere a user can see by default (the DEBUG-level Stop log stamps it
but DEBUG is off). When a user reports "Weave isn't showing X for the
turn I just had," the first ask is always "give me the trace_id" — and
without one, the only recourse is full-corpus query filtering.

Add `src/traceRegistry.ts`: an append-only JSON file at
`~/.weave_claude_plugin/trace-registry.json` with one entry per turn
(session_id, turn_number, trace_id, conversation_id, started_at,
ended_at, tool_count, subagent_count, cwd). Bounded at 1000 entries
with FIFO eviction. Atomic-ish writes via rename. Best-effort: silent
on I/O errors, since failing to persist a breadcrumb is non-fatal —
the turn span itself is still exported.

Wire `recordTurn(...)` into `handleStop` immediately after the turn
span ends.

Add `weave-claude-plugin trace recent [--limit N]` and
`weave-claude-plugin trace lookup --session <id>` /
`weave-claude-plugin trace lookup --trace <prefix>` CLI commands so
users can pull the trace_id without needing to re-enable DEBUG and
re-trigger the bug.

scripts/smoke/verify-trace-registry.mjs runs the daemon end-to-end with
HOME redirected to a tmp dir, drives 3 turns across 2 sessions, and
asserts every registry/lookup surface — file written, entries
recorded, recentTurns ordering, per-session filter, trace-prefix
resolver, cwd capture, schema-version pinning. 11/11 checks pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@w-b-hivemind
Copy link
Copy Markdown

w-b-hivemind Bot commented May 22, 2026

HiveMind Sessions

1 session · 1h 21m · $69

Session Agent Duration Tokens Cost Lines
Debugging and Fixing Weave Agent Trace Parser
80124e7a-03c1-4226-b050-a7a8eec58c90
claude 1h 21m 294.1K $69 +2001 -238
Total 1h 21m 294.1K $69 +2001 -238

View all sessions in HiveMind →

Run claude --resume 80124e7a-03c1-4226-b050-a7a8eec58c90 to pickup where you left off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant