Repository navigation
fix(score): read real Claude Code transcripts - #7
Merged
Merged
Conversation
The transcript structs required fields named `_uuid`, `_role`, `_id`, `_text` and so on, which real transcripts never contain, so every assistant line failed to parse and every session scored as if it ran no commands. Declare only the fields the scorer uses and let serde ignore the rest. Count unreadable lines, and report sessions with no readable assistant message instead of grading them. Name project dirs like Claude Code does: every non-alphanumeric character becomes `-`, not only `/` (`.worktrees` -> `--worktrees`). Implements [[tasks/harmony-2770]]
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
What and why
agent scoreread nothing from real Claude Code transcripts. The serde structs required fields literally named_uuid,_role,_id,_text,_tool_use_id, … which real transcripts never have (they useuuid,role,id, …). Every assistant line failed to parse, was silently skipped, and every session was graded as if it ran zero commands (found during #6, KBtasks/harmony-2768).This PR:
sessionId,timestampandmessage.content; a content block is eithertool_use(name,input) or ignored. Every other line type (user,attachment,mode,ai-title, …), block type (text,thinking, …) and unknown field is ignored, so new transcript fields don't break it.skipped_lines, in--jsonand in the Markdown summary when non-zero) instead of dropping them silently.--jsonalso gainsassistant_messages(assistant lines read).No readable sessions to score.-, not only/:/home/gsc/.cache/p→-home-gsc--cache-p,…/harmony/.worktrees/x→…-harmony--worktrees-x(checked against the dirs in~/.claude/projects/). On main,agent scorein any path with a.,_or space looked in the wrong dir.Not handled (all pre-existing, and none seen in the local
~/.claude/projects/): a path with a non-BMP character such as an emoji (JavaScript likely makes that--, this makes-); Windows, wherecanonicalize()adds a\\?\prefix; and Claude Code shortening very long dir names (over ~200 chars) with a hash suffix. There's nothing local to check the exact rules against, so they're left out.Verification
Same real session (~7,000 lines, 994+ Bash calls), copied into a scratch HOME. Before (main):
After:
Hand count with
jqover the same file: 999 Bashtool_useblocks, 562 containinggit, 1 starting withmeta git, 51 containinggit commit, 0meta git status/diff(hence 0% awareness), nometa context/meta project list. All match. (The low grade is accurate: that session used plaingitin sub-repos.)From a scratch HOME at a path containing
.cache, main fails withExpected directory: …/-home-gsc-.cache-claude-tmp-…while Claude Code's dir is…/-home-gsc--cache-claude-tmp-…; the fix finds it. A file holding only amodeline and a non-JSON line printsNot scoring …: no assistant messages could be read (1 unreadable lines)and exits 1.Tests: new
test_parse_real_transcript_formatreadstests/fixtures/transcript.jsonl, built from the real line shapes (real keys, placeholder values; no prompts, paths, emails or tokens) with user/attachment/mode/last-prompt lines, thinking/text/tool_use blocks, a non-Bash tool, and one truncated line. Run against main's parser (with theskipped_linesassertion removed, since that field doesn't exist on main) it fails withleft: "" right: "fixture-session"; it passes here.cargo testandcargo clippy --all-targets --all-features -- -D warningspass locally.Look closely at
handle_scorenow skips unreadable sessions and errors only when none are readable, so--recent Nstill scores the readable ones.Message.contentis nowVec<ContentBlock>: an assistant line whosecontentisn't an array counts as unreadable. Real assistant lines always use an array (2,077/2,077 in the sampled session).Implements KB
tasks/harmony-2770.