fix(round-trip-tracker): detect SessionStart hook brain context#93
Open
rajkripal wants to merge 1 commit into
Open
fix(round-trip-tracker): detect SessionStart hook brain context#93rajkripal wants to merge 1 commit into
rajkripal wants to merge 1 commit into
Conversation
Claude Code stores hook outputs as JSONL entries with type="attachment"
and content in entry["attachment"]["content"]. The tracker's load_from_jsonl
checked entry.get("message") to gate the attachment branch, but attachment
entries have no "message" field, so all hook content was silently dropped.
Two bugs fixed:
1. Attachment entries now read content from entry["attachment"]["content"]
(falling back to "stdout") and use role="hook" so chain logic ignores
them as chain starts but brain detection can still see them.
2. detect_session_brain_preamble() now scans hook + user messages up to
and including the first chain, so a SessionStart brain query marks all
chains in that session as brain_used=True.
Also adds this script to the cashew repo (was an untracked workspace file)
so it can be version-controlled alongside the tracking log it writes to.
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.
Claude Code stores hook outputs as JSONL entries with `type="attachment"`
and content in `entry["attachment"]["content"]`. The tracker's
`load_from_jsonl` gated the attachment branch on `entry.get("message")`,
but attachment entries have no `message` field, so all hook content was
silently dropped. This is why brain usage has shown 0% for weeks despite
the SessionStart hook firing on every interactive session.
Two bugs fixed:
(with `stdout` as fallback) and store as `role="hook"`. The hook role
is excluded from chain detection but visible to brain detection.
the first chain start. If a SessionStart hook injected brain context before
any task began, all chains in that session are marked `brain_used=True`.
Also moves this script from the untracked workspace `scripts/` dir into the
cashew repo, where it belongs alongside the tracking log it writes to.