Skip to content

conversation-trace: Support mixed-type payload batches and add raw Claude hook event support#67

Open
stefanskoricdev wants to merge 5 commits into
mainfrom
feat/claude-conversation
Open

conversation-trace: Support mixed-type payload batches and add raw Claude hook event support#67
stefanskoricdev wants to merge 5 commits into
mainfrom
feat/claude-conversation

Conversation

@stefanskoricdev

Copy link
Copy Markdown
Contributor

No description provided.

stefanskoricdev and others added 4 commits June 12, 2026 13:12
…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>
@stefanskoricdev stefanskoricdev changed the title agent-trace: Rework conversation-trace payload to flat mixed-batch format conversation-trace: Support mixed-type payload batches and add raw Claude hook event support Jun 12, 2026
…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>
@stefanskoricdev stefanskoricdev marked this pull request as ready for review June 12, 2026 15:29
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