Repository navigation
Fix trail's save-a-learning prompts - #739
Conversation
🌱 graft blast radius4 areas changed → 11 areas can be affected. 42 dependent symbols, depth 2. flowchart TB
A0(("Hook Management<br/>16 symbols"))
A1(("Initialization Process<br/>7 symbols"))
A2(("Note Management<br/>4 symbols"))
A3(("Cloud Session Sharing<br/>4 symbols"))
A4(("Skill Offerings<br/>2 symbols"))
AX(("6 smaller areas<br/>9 symbols"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1,A2,A3,A4 reached;
classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
class AX tail;
Who knows this code — 4 people across 15 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no All 42 dependent symbols, grouped by areaHook Management — 16 symbols in 13 files
Initialization Process — 7 symbols in 6 files
Note Management — 4 symbols in 4 files
Cloud Session Sharing — 4 symbols in 4 files
Skill Offerings — 2 symbols in 2 files
Host Registry — 2 symbols in 2 files
Session Management — 2 symbols in 1 file
Telemetry Tracking — 2 symbols in 2 files
Command Line Interface — 1 symbol in 1 file
Tool Management — 1 symbol in 1 file
Dialect Tracking — 1 symbol in 1 file
Test signal per changed area — 1 ✓ · 2 ✗ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
124 test suites also reference this code125 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see the code that changed, and the line that reaches it. |
Issue: In Claude Desktop, a user's correction never led to a "save a learning" ask. After a long session was compacted, the Stop hook asked about a correction nobody made ("The user corrected you ("This session is being continued…")"). After a push, it said no learning went with the work when one had.
Why: The hook's
typed()had its own filter. It dropped anything starting with<, which is every Desktop message (they open with a<system-reminder>block), and it let Claude Code's compaction summary and other sessions' messages through as typed. Its advice also sent business reasoning to the repo, and it counted writes outside the repo as code edits.Fix: The hook now reads typed words through the shared transcript filter, knows more "keep it out of the repo" phrasings, says business reasoning goes in
--personal, and ignores writes outside the repo or pushes whose branch already adds a learning.Moves: share of user corrections that end in a saved learning. Measured by the new
note_askedevent in PostHog (Metabase db 11,posthog_event_full_view):kind = correctedwithsavedin (repo,personal) over allkind = corrected. Value today: none. Nothing measured it before this PR, and db 11 has nonote_askedevents (checked 2026-11-16).What changed
typed()usestypedText(src/trace/claude.ts), the filter every other learning path already uses. It strips<system-reminder>and IDE wrappers and keeps the words after them. It never counts compaction summaries (isCompactSummary, or text starting "This session is being continued"), task notices or other sessions' messages (origin.kindother thanhuman) as typed. A queued message typed while Claude was busy now counts too.ownTextopens "[Artifact comment sent to Claude]" to its quoted comment between the BEGIN/END lines. Before, the whole harness wrapper counted as typed on every learning path.na,need not / needn't go|be,shouldn't go,keep it out of the repo,not in the repo(not when the sentence is a question). Tests cover look-alikes that must stay quiet: "is this not in the repo yet?", "you need not ask…", "nan values…", "naming is fine".format.ts), the trail skill (skill-template.ts) and the corrected and shipped asks now say business, growth, sign-up, pricing or competitor reasoning and internal numbers go in--personal, never the repo, "even if you also keep your own copy" (the answer to why Claude's own memory got the rule and trail didn't). The words test bans "memory" in agent-facing text, hence "your own copy".shellEditreturns no edit when a command starts withcdoutside the repo, or when every full path it names is outside the repo (a scratch PR body via$P, Claude's memory index). A write it can't name from inside the repo still counts. The shipped sign is skipped when the branch's commits already add a.trail/learnings/file (branchAddsLearninginsrc/cloud/diff.ts, next tobranchDiff).note_asked{kind,saved:repo/personal/no}, sent on the stop after an ask (thestop_hook_activestop).askAnsweronly counts it when the last Stop hook feedback is trail's own ask, so another hook's block isn't counted. Listed incontract.ts, its allowed values,TELEMETRY.mdand the pinned event list.Choices made
hook_ms(the Stop hook's only event today) is sent only when learned skills are enabled, and a property onnote_savedalone gives saves without the asks they answer, so no share.contract.ts,TELEMETRY.mdand the pinned event list intest/telemetry-contract.test.tsalso change in Ask once whether a reused learning helped #727 (addslearning_rated). Main now has twenty-seven events and this PR pins twenty-eight; whichever of the two merges second needs "twenty-nine" and both names.trail check
Exits 1 with 6 hits, all word overlaps with unrelated learnings, not conflicts:
TELEMETRY.md:57(thenote_askedrow) andnote-signals.ts:152(thetyped()comment) vs hooks going quiet under a sandboxedclaude -p(matched on "claude", "stop", "hook", "tool").format.ts:417(the session-start--personalsentence) vs the hook shim with a real HOME ("copy"), showing the person one line of hook output ("show", "person", "one"), and the old--no-statuslineREADME advice ("keep", "line").note-signals.ts:82(FULL_PATH) vsreplaces:holding ids ("file name").Tests
test/trail-note-ask.test.ts,test/trace-typed.test.ts,test/telemetry-contract.test.ts,test/trail-words.test.ts,test/claude-stop.test.ts: 61 pass.origin/main(dd0e6cb), the same parser/extraction set from the worktree resolving the main checkout'snode_modules. Nothing new fails.skill-template.tsand the skill fixture keep both this PR's--personallines and Install trail without sudo #734's no-sudo lines. Typecheck is clean, and the tests above pluscli-meta,node-version,claude-shim-resolve,trail-notesandskills-fixturespass (130).TELEMETRY.md,contract.tsand the pinned event list. Kept main'sintoonnote_savedand itssession_shared/share_bundleevents, addednote_askedbeside them. Main hadn't changednote-signals.ts,stop.tsortrace/claude.tssince the last merge, and itstyped()still has the old filter, so the fix applies unchanged. Typecheck is clean and the five files above pass (63). Full suite with a scratch HOME: 4,505 tests on this branch, 4,499 on main (b22055d). 3 fail on each, the same three on both: the graft-to-trail move tests, which depend on this machine having trail installed. Nothing new fails.trail checkgives the same 6 hits listed above.noteSignals, a line followed by an edit. main asks "The user corrected you" on a flagged compaction summary, on the same summary without flags, and on anorigin: peermessage; this branch stays quiet on all three. Both ask on "no, use a channel instead…"; only this branch asks on "na, these learnings need not go to repo" behind the Desktop status block.🤖 Generated with Claude Code