feat: per-turn trace registry + weave-claude-plugin trace commands#57
Draft
rgao-coreweave wants to merge 1 commit into
Draft
feat: per-turn trace registry + weave-claude-plugin trace commands#57rgao-coreweave wants to merge 1 commit into
rgao-coreweave wants to merge 1 commit into
Conversation
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>
HiveMind Sessions1 session · 1h 21m · $69
View all sessions in HiveMind → Run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/traceRegistry.ts: append-only JSON file at~/.weave_claude_plugin/trace-registry.jsonwith 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 intohandleStopimmediately after the turn span ends. Best-effort — silent on I/O errors.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 subagentsrefactor, every turn is its own root trace, but the daemon doesn't surface itstrace_idanywhere 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,recentTurnsordering, per-session filter, trace-prefix resolver, cwd capture, schema-version pinning. 11/11 checks pass.weave-claude-plugin trace --helpandtrace recentsmoke-tested locally.npm run buildclean.🤖 Generated with Claude Code