conversation-trace: Support mixed-type payload batches and add raw Claude hook event support#67
Open
stefanskoricdev wants to merge 5 commits into
Open
conversation-trace: Support mixed-type payload batches and add raw Claude hook event support#67stefanskoricdev wants to merge 5 commits into
stefanskoricdev wants to merge 5 commits into
Conversation
…rmat Remove the nested typed-batch envelope pattern where top-level `type` classified a homogeneous `payloads[]` array with items that carried no own type. Replace it with a flat mixed-batch shape where each item in `payloads[]` declares its own `type` discriminator (`message.updated` or `message.part.updated`). - Plugin-side: `buildPatchConversationTracePayloads` (plural, returning array) replaced by `buildPatchConversationTracePayload` (singular, returning one envelope); same-kind old-envelope helpers removed. - Diff-backed message.updated events now dispatch one mixed envelope containing the synthetic parent item plus patch part items rather than concurrent individual envelopes. - Rust hook: drops top-level envelope `type` classification; parses per-item `type` directly. Success output renamed from `persisted=<n>` to separate `persisted_messages=<n>, persisted_parts=<n>`. - .claude/settings.json: register event-logger.sh on UserPromptSubmit, PreToolUse, and Stop events for broader debug telemetry. Co-authored-by: SCE <sce@crocoder.dev>
…ation-trace intake Add transform_claude_user_prompt_submit and its injectable counterpart to convert raw Claude UserPromptSubmit hook events into two normalized items (message.updated with role: "user", message.part.updated with part_type: "text") sharing the same generated UUIDv7 message_id and the event session_id. The event prompt field becomes the part text. The classification branch in parse_conversation_trace_payload detects top-level hook_event_name and routes through the new transformer before the existing mixed-batch payloads path. Unsupported hook_event_name values fail deterministically with a diagnostic that includes the event name and raw content. Context docs (context-map.md, glossary.md, agent-trace-hooks-command- routing.md) are updated to reflect the new raw Claude event path. Co-authored-by: SCE <sce@crocoder.dev>
Previously only `UserPromptSubmit` was supported in the raw Claude hook event classification path of `parse_conversation_trace_payload`. Claude `Stop` events were rejected with a misleading error. Replace the single-branch guard with a `match` on `hook_event_name` that routes `"UserPromptSubmit"` to `transform_claude_user_prompt_submit`, `"Stop"` to the new `transform_claude_stop` (which validates `session_id` and `last_assistant_message`, generates a UUIDv7 `message_id`, and produces normalized `message.updated` + `message.part.updated` items with `role: "assistant"`), and any other value to a descriptive error listing supported events. Co-authored-by: SCE <sce@crocoder.dev>
Implement `transform_claude_post_tool_use` to handle raw Claude PostToolUse hook events in the conversation-trace intake pipeline. For Write/Edit tool events, the transformer reads `tool_response.structuredPatch` and produces one `message.updated` item plus per-patch-item `message.part.updated` items. Non-Write/Edit tools (Read, Think) are silently skipped. Wire PostToolUse into `parse_conversation_trace_payload` so it is routed alongside existing UserPromptSubmit and Stop handlers. Update Claude hook settings (both local `.claude/settings.json` and generated `config/.claude/settings.json`) to register `sce hooks conversation-trace` for PostToolUse, UserPromptSubmit, and Stop events, replacing the former bash-based event-logger script. Update context docs (glossary, overview, and command-routing doc) to reflect the new PostToolUse transformer and its behavior. Co-authored-by: SCE <sce@crocoder.dev>
…message.part` Renames the `type` field values in conversation-trace STDIN envelopes from `message.updated` to `message` and from `message.part.updated` to `message.part`. The `.updated` suffix was redundant since conversation- trace events always represent the latest state, and the shorter names align with the schema's intent as a normalized batch format. Updated: TypeScript plugin source (config/lib/agent-trace-plugin), three generated plugin copies (.opencode/plugins, config/.opencode/plugins, config/automated/.opencode/plugins), Rust hook parser constants/error messages/test payloads (cli/src/services/hooks/mod.rs), shell stress test (scripts/stress-test-conversation-trace-firehose-mixed.sh), and all context documents referencing the old discriminators. Co-authored-by: SCE <sce@crocoder.dev>
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.
No description provided.