Skip to content

fix(trail): learnings reach Claude on file open, plus setup fixes - #642

Open
anirudhkumar-nanonets wants to merge 1 commit into
mainfrom
fix/trail-interview-bugs
Open

anirudhkumar-nanonets wants to merge 1 commit into
mainfrom
fix/trail-interview-bugs

Conversation

@anirudhkumar-nanonets

Copy link
Copy Markdown
Collaborator

Fixes the software bugs from the 16 Oct Trail user tests.

Moves: learnings_committed (PostHog, database 11; query in daily/project.md). Today's value isn't filled in because Metabase isn't connected in this session. Baseline 0 on 13 Oct.

What changes

  • Learnings reach Claude when it opens the file they're about. The PostToolUse hooks on Read, Edit, Write and Bash add the learnings whose touches name that file, once a session, two at most. Claude no longer has to call trail to get them. Checked in a real Sonnet session on app-to-agents-migration.
  • A learning's touches come from the session transcript: files edited, then files named in the note, then files read. Before, every note listed whatever untracked files sat in the repo.
  • An empty trail grep names the git-ignored code it didn't search instead of saying all code was searched. The migration repo keeps the old app code in ignored source_models/ folders.
  • Exploratory turns get the learning ask too. The Stop hook also asks when trail's answers stood in for 30k+ tokens of reading. trail answers most questions in 1 or 2 calls, so those turns never reached the 3-call bar.
  • trail init refuses the home folder. In other folders outside git it says the learnings stay on this machine, instead of saying to commit.

Not changed: "skill not loaded on Sonnet" didn't reproduce. Sonnet started with trail ask in 3 of 3 runs.

Testing

  • New tests: init-guard, ignored-code, trail-learning-on-touch, plus cases in trail-home and trail-note-ask. 59 pass across the touched files.
  • Full suite with a scratch HOME: 1,451 of 1,455. The 3 failures (graft-to-trail, hosts-trail, upkeep-hooks) fail on clean main on this machine too.
  • Run the suite with a scratch HOME. A plain npm test deleted the user-level trail hooks and skill in ~/.claude.

trail check

It flags 3 to 7 conflicts (the count changes between runs), all against the "Tried and ruled out" section of the learning this PR adds. The code follows that learning's Decided section: refuse only the home folder, and no fix for Sonnet. So it ships as is, and a learning in this PR records the false match.

🤖 Generated with Claude Code

@trailhq-graft

trailhq-graft Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🌱 graft blast radius

5 areas changed → 2 areas can be affected. 2 dependent symbols, depth 2.
Tests: no test reaches MCP Tool Invocation; 4 areas updated their tests.
Tag: @shhdwi — 6 of 7 areas

flowchart TB
  A0(("Workspace Grep<br/>1 symbol"))
  A1(("MCP Server<br/>1 symbol"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0,A1 reached;
Loading
Can be affected Symbols Nearest hop Reached from
Workspace Grep 1 src/graph/workspace-cli.ts:L113-L130 runWorkspaceGrep — calls, depth 1 Search Grep CLI
MCP Server 1 src/mcp/server.ts:L73-L155 startMcpServer — calls, depth 2 MCP Tool Invocation
Who knows this code — 1 person across 7 areas
Area Who knows it
Search Grep CLI · changed @shhdwi — 4 commits, last 5d ago
MCP Tool Invocation · changed @shhdwi — 15 commits, last 5d ago
CLI Initialization · changed @shhdwi — 26 commits, last 4d ago
learningsOnTouch · changed @shhdwi — 15 commits, last 5d ago
Workspace Grep · affected @shhdwi — 5 commits, last 5d ago
MCP Server · affected @shhdwi — 2 commits, last 3mo ago
Session Notes · changed only you — nobody else has touched these files

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 @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 2 dependent symbols, grouped by area

Workspace Grep — 1 symbol in 1 file

  • src/graph/workspace-cli.ts:L113-L130 — runWorkspaceGrep (calls, depth 1)
    125: console.error(coverage ? `${zeroHitNote(result)}\n${coverage}` : zeroHitNote(result));

MCP Server — 1 symbol in 1 file

  • src/mcp/server.ts:L73-L155 — startMcpServer (calls, depth 2)
    74: // The self-maintenance pass, run once at boot. This is the ONLY channel that
Test signal per changed area — 4 ✓ · 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.

  • ✓ Search Grep CLI — 2 of 5 reached · 1 test file changed here: test/ignored-code.test.ts
    • not reached: runGrepCommand, holdsCode, ignoredLabel
  • ✗ MCP Tool Invocation — 0 of 1 reached · no test file reaches it
    • not reached: callSingleTool
  • ✓ Session Notes — 2 of 6 reached · 1 test file changed here: test/trail-home.test.ts
    • not reached: changedFiles, entryFor, add, place
  • ✓ CLI Initialization — 2 of 4 reached · 1 test file changed here: test/init-guard.test.ts
    • not reached: runNoteCommand, runInitCommand
  • ✓ learningsOnTouch — 1 of 7 reached · 1 test file changed here: test/trail-note-ask.test.ts
    • not reached: commandNames, about, handlePostEdit, handleToolUse, learningsOnTouch, codeReadIn
8 test suites also reference this code

8 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/graph-follow-submodules.test.ts
  • test/graph-load.test.ts
  • test/graph-refresh.test.ts
  • test/graph-seed.test.ts
  • test/mcp-tools.test.ts
  • test/search-grep.test.ts
  • test/trail-notes.test.ts
  • test/trail-spelling.test.ts

⚠️ 2 changed files not in the graph (.trail/learnings/2026-10-19-interview-bug-fixes-and-npm-test-anirudhkumar.md, .trail/learnings/2026-10-19-trail-check-flags-a-branch-against-anirudhkumar.md) — no parser claims the extension, or the index predates the file.

graft blast · origin/main...HEAD · depth 2 · 17 changed files

Open the interactive graph → — click an area to see its dependent symbols at file:line.

github-actions Bot added a commit that referenced this pull request Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant