Repository navigation
fix(session-analysis): recognize lowercase edit tool names from Pi sessions - #157
Merged
Merged
Conversation
…ssions Pi's coding agent emits lowercase tool names (edit, write), while the edit-event detection in episode-contract and insights matched Claude Code's capitalized names (Edit, Write) with a case-sensitive Set lookup. Every Pi edit event was therefore missed, which surfaced as withChanges: 0 in session facts for any workspace with real commits. Store the edit tool names lowercase and compare against the lowercased tool name, matching the existing case-insensitive check used for PATHLESS_EDIT_TOOL_NAMES in the same function. Validation: reran session-analysis facts --platform pi over a 254-session workspace; populationCoverage.withChanges moved 0 -> 29, candidate classes gained change-gap 11, and read-only-work dropped 44 -> 21 as editing episodes were no longer misclassified. The existing episode contract and lifecycle signal tests (28 tests, all using capitalized Claude tool names) pass unchanged, confirming backward compatibility.
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.
Why
Pi's coding agent emits lowercase tool names (
edit,write), but edit-event detection inepisode-contract.mjsandinsights.mjsmatched Claude Code's capitalized names (Edit,Write) with a case-sensitiveSetlookup:Every Pi edit event was therefore missed, which surfaces as
withChanges: 0in session facts for any Pi workspace that demonstrably has commits — meaning Task-Episode change evidence,change-gapclassification, andread-only-workcorrection are all broken for thepiplatform.Notably, the same function already lowercases its input for
PATHLESS_EDIT_TOOL_NAMES(apply_patch), so case-insensitive matching is the established intent here; the main set just never got the same treatment.What changed
scripts/session-analysis/episode-contract.mjs:EDIT_TOOL_NAMESentries stored lowercase;isEditEventcompares againstString(toolName ?? "").toLowerCase()scripts/session-analysis/insights.mjs: same fix for its localEDIT_TOOL_NAMEScopy, plus null-safe tool-name accessNo behavior change for capitalized providers:
"Edit".toLowerCase()still matches, and the match set strictly grows.Validation
Reran
session-analysis facts --platform piover a 254-session workspace before/after:populationCoverage.withChangeschange-gapread-only-workcandidateEpisodesThe workspace had ~500 commits in the analyzed window, so
withChanges: 0was provably a detection failure, not a read-only window.Backward compatibility: the existing
session-episode-contractandlifecycle-demand-signalstests (28 tests, all using capitalized Claude tool names) pass unchanged, and a spot check against a real Claude session (Writetool calls) confirmsisEditEventstill returnstruefor capitalized names whileBash/Readstayfalse.