Repository navigation
Get overlap warnings ready to go live - #738
anirudhkumar-nanonets wants to merge 13 commits into
Conversation
… follow-ups trail check flags TELEMETRY.md:71 against the Oct 27 learning on Claude's real HOME: a word match on "Claude ... trail ... never" in the new telemetry row, not the same change.
🌱 graft blast radius3 areas changed → 10 areas can be affected. 52 dependent symbols, depth 2. flowchart TB
A0(("Cloud Workspace Sync<br/>13 symbols"))
A1(("Claude Session Metrics<br/>13 symbols"))
A2(("Team CLI<br/>9 symbols"))
A3(("Notes And Reviews<br/>5 symbols"))
A4(("Onboarding Flow<br/>4 symbols"))
AX(("5 smaller areas<br/>8 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 13 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 52 dependent symbols, grouped by areaCloud Workspace Sync — 13 symbols in 6 files
Claude Session Metrics — 13 symbols in 12 files
Team CLI — 9 symbols in 1 file
Notes And Reviews — 5 symbols in 4 files
Onboarding Flow — 4 symbols in 4 files
Telemetry Tracking — 3 symbols in 3 files
MCP Server — 2 symbols in 2 files
CLI Skills — 1 symbol in 1 file
Learn Sessions — 1 symbol in 1 file
Workspace CLI Graph — 1 symbol in 1 file
Test signal per changed area — 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.
70 test suites also reference this code84 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 its dependent symbols at file:line. |
trail check flags TELEMETRY.md:71 and hooks.ts:113 against the Oct 27 learning on Claude's real HOME: word matches ("claude ... trail", "trail ... never ... loads"), not the same change.
…e one way trail check flags TELEMETRY.md and hooks.ts lines against the Oct 27 learning on Claude's real HOME (word matches on "Claude ... copy ... project"), and the listNotes line against the Oct 22 learning on filtering inside listNotes: this only changes which checkout listNotes reads, no filter is added.
# Conflicts: # test/telemetry-contract.test.ts
# Conflicts: # test/telemetry-contract.test.ts
The issue: in Claude Desktop worktree sessions, overlap warnings never fired, and a learning saved on the worktree's own branch never reached Claude when it opened or edited the file it lists. Where overlap warnings did fire, they warned about branches that were already merged: without
gh, 2 in 3 warnings on this repo were false alarms. And a doc comment Claude added above a function a teammate is changing gave no warning.Why: in a worktree session the hooks take the main checkout as the project (
CLAUDE_PROJECT_DIR), so an edited file came out as.claude/worktrees/<name>/src/...and matched no branch. Learnings on file touch were read only from the main checkout (main's #733 fixed the file's name for them, not where they're read). Separately, Trail-Code squash-merges PRs and leaves the branch on GitHub, so git still calls a merged branch open. And Claude's Edit repeats a line or two it doesn't change to anchor the edit, like the}closing the code above; the check counted those as edited and took the smallest symbol they touched.The fix: both hooks now name the file from the checkout it's in, and learnings on touch come from both checkouts. Overlap warnings skip a function whose added lines were already added on main (
git log -S), and they also cover the person's own other open branches, never the one they're on. Three events count what reaches Claude:overlap_warned,overlap_actedandlearnings_on_touch.Moves:
overlap_warnedwithpr=open÷overlap_warnedwithpr≠unknown(split bywhose). Acted =overlap_acted÷overlap_warned.learnings_on_touchwithworktree=true.posthog_event_full_view). Today: 0. None of these events existed (I queried the last 3 days foroverlap%and got 0 rows).ghand from 32% to 93% without it, and none of the 86 real warnings were dropped.What changed
src/notes/home.ts:otherCheckout(project, file)returns the checkoutfileis in when it's another checkout of the same repo (a linked worktree), comparing the shared git dirs by the OS's real path (realpathSync.native), so a Windows 8.3 short name likeRUNNER~1in one of them doesn't hide the worktree. A file in the project's own checkout, outside git, or in another repo (a submodule included) gives null.src/claude/hooks.ts:editOverlapcompares from that checkout, reading the branch list the session start wrote for the project. It usespayloadSessionIdlike the prompt hook.learningsOnTouchnames the file from that checkout and reads learnings from both the project and that checkout, so a learning on the worktree's branch counts. A learning in both comes from the project, where the session-start and prompt hooks read it, so it's shown once. Make trail work in Claude Desktop and Codex #733 had added its own same-repo check here (sameRepo, runninggit rev-parsein both folders); the merge keeps one check,otherCheckout, which reads git's files instead of running git.src/notes/edit-overlap.ts:landedSincedrops a function when each of the 3 longest lines (12+ characters) the branch added to it was also added on main since the fork. It runs only when both changes land in the same function, at about 7 ms per check.new_stringkeeps fromold_stringat either end (anchors). A comment block directly above a function is part of it (withComment), since Go doc comments and JSDoc sit outside the span the parser gives the function. A CRLF file is searched as LF: Edit's text has\n, and Claude Code writes it in the file's own line endings.mine, and the directive says "Your other open branch … also changes …".src/notes/branches.ts: the samegh pr listcall also keeps which branches have an open PR (open), forpr: open | none | unknown.src/claude/overlap-telemetry.ts(new):overlap_warnedfires per warning shown, withprandwhose(teammate or mine).overlap_actedfires once per warning, when a later prompt in that session names the teammate or the branch.learnings_on_touchfires inlearningsOnTouchwithvia(read, edit or command) andworktree(true or false).TELEMETRY.mdandcontract.ts: the three events, all with closed-set values. No names, branches or paths travel.How I found and measured it
withLock()in a Desktop worktree session with trail 0.26.0 installed. A teammate's open Wait instead of crashing when Windows refuses a lock file that's being deleted #682 changes that function. The hook ran and returned the blast radius but no overlap line. Its session and stats files were written under the main checkout. The new worktree tests for both hooks fail without the fix and pass with it.functionOverlaps, as a teammate with no branches of their own, and counted a warning as real when its branch has an open PR (gh pr list):End to end: two test users, two isolated machines, real Claude Code
Kumar and Priya below are made-up test users. Each has their own
HOME,.gitconfig, npm prefix with@trailhq/trail-codepacked from this branch, clone, andtrail init -y. Their hooks are wired into their own~/.claude/settings.json. Each also has their own telemetry listener on localhost (GRAFT_POSTHOG_HOST). They share only a bare git remote standing in for GitHub; the macOS keychain folder is linked in soclaudecan sign in.Overlap warnings. Kumar pushed
kumar/backoff, which changesbackoff(). Priya pushedpriya/retries, which changesretries(), then added a worktree.claude -pfrom Priya's main clone, editing the worktree's copy, which is the desktop-app setup. Claude's reply ended with:claude -pin Kumar's clone, editingretries():git diff origin/main...origin/<branch>the warning names before answering./batch/: Priya sentoverlap_warnedwith whose=teammate and with whose=mine, thenoverlap_actedwith whose=teammate after a follow-up prompt named Kumar. Kumar sentoverlap_warnedwith whose=teammate.prwasunknown(nogh), and no event carried names, branches or paths.Learnings on file touch. In Priya's setup, Claude reads the worktree's copy of
src/retry.ts, which a learning on the worktree's branch lists.learningsOnTouchfix): the learning did not reach Claude.learnings_on_touchwas queued with via=read and worktree=true.Live, in Claude Desktop
On 30 Oct I installed this branch's build globally and ran three Desktop worktree sessions on another repo of ours (Go), each asked to add a one-line comment to one function:
git diffit names, and ended with a correct "🔀 trail ·" line about a likely one-line merge conflict. The session recorded it aspr=open,whose=teammate.funcand anchored the Edit on the}closing the struct above. No warning: the edit's lines ran from the struct's last line to thefuncline, and the struct was the smaller symbol. With the anchor and doc-comment fix, replaying that exact Edit warns about the right branch and function, and the other two come out the same.Choices I made
git log -Son the branch's added lines rather than comparing the function's text with main's. Comparing text dropped only 119 of 182 merged-branch warnings, because main often changes a function again after the merge.otherCheckout) serves both hooks. Without it,learningsOnTouchwould read another repo's learnings for a file Claude opened there.Follow-ups (not in this PR)
openlist. That removes the 16 false alarms left withgh.gh, merged branches fill the 30-branch cap and push out real ones (7 here). Run the added-lines check when the list is built.notesOnTouchgets the project dir for its stale check (from Flag learnings that name code that's gone #731). In a worktree session it should get the file's checkout, so a learning on a file only the worktree has isn't marked stale.Checks
b22055dc). Conflicts were inlearningsOnTouch(Make trail work in Claude Desktop and Codex #733 had fixed the file's name there too; see What changed) and the event list intelemetry-contract.test.ts.8b56ca07), with no conflicts. Then Fix trail's save-a-learning prompts #739 (to783f1ea6): the only conflict was the pinned event list intelemetry-contract.test.ts.49d36b7c, with init ends by showing Trail on your own last task (prototype) #757, Allowlist test/ fixtures in gitleaks #842, share-session survives deeply nested sessions #844 and share-session says what to type, folder numbers included #847). The only conflict was the same pinned list, which now keeps all 32 events: Fix trail's save-a-learning prompts #739'snote_asked, Ask once whether a reused learning helped #727'slearning_ratedand this PR's three.TELEMETRY.mdandcontract.tsmerged on their own each time. Ask once whether a reused learning helped #727 doesn't touchhooks.ts. Its "did it help?" vote takes the learning's id fromnotesOnTouch, whichlearningsOnTouchcalls with the project's session, so a learning read from the worktree can be voted on too.npm testwith a scratch HOME after the 18 Nov merge (42e37baa): 4,545 pass and 3 fail. The same three (graft-to-trail,hosts-trail,upkeep-hooks) fail on unchanged main49d36b7c. On 17 Nov,hooks-fifoand a parallel-batch test incontext-synth-concurrency.test.tseach failed once and passed alone 3 times out of 3; this PR touches neither, andhooks-fifofails on main too. In an earlier run,personAtTerminal reads the real process table…inskills-store-held.test.tsfailed once under load; it reads the live process table, passes alone, and this PR doesn't touch it.trail check: 5 conflicts, none of them real.TELEMETRY.md:73andhooks.ts:127are word matches ("Claude … whose", "trail … never … loads") against the Oct 27 learning on Claude's real HOME.TELEMETRY.md:73also matches ("worktree … session … project") the Nov 5 learning ontrail initfinding few past sessions, which came in with init ends by showing Trail on your own last task (prototype) #757; that one is about finding past transcripts, and this PR's rows are about hooks naming a file from its worktree.hooks.ts:7matches the Oct 22 learning on filtering insidelistNotes; this callslistNotesfor a second checkout and adds no filter inside it.contract.ts:144is a word match ("one … file … learning") against the Oct 29 learning on how long reading one touched file takes.This takes in what was #741, which I closed.
🤖 Generated with Claude Code