Skip to content

Measure onboarding tokens on the last merged PR - #677

Merged
shhdwi merged 1 commit into
mainfrom
feat/last-pr-tokens
Oct 23, 2026
Merged

shhdwi merged 1 commit into
mainfrom
feat/last-pr-tokens

Conversation

@shhdwi

@shhdwi shhdwi commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

The onboarding page's token card measured one lookup on the repo's most central symbol. It read like a demo, and the review asked for "tokens your last PR would have saved".

What changes

  • lastMergedPrs(repo) reads git's history on the default branch (origin/HEAD, else HEAD). It finds merged PRs from merge commits (Merge pull request #N from …, title on the body's first line) and squash merges (Title (#N)). It skips bots, release chores and PRs that changed no product code still in the repo. No network and no GitHub API.
  • tokensOnOneLookup tries the last PR first. The question is the PR's title, the lookup an agent starting that PR would make, and it's measured exactly as before (ask's pack against reading the files it covers whole). With no such PR it falls back to the central-symbol lookup.
  • The summary's tokens.pr carries { number, title, url, files (≤20), changed, found }. found is how many of the PR's code files the answer pointed to.
  • The live progress line names the PR.

Real runs

Tests

  • A new test covers the squash and merge-commit forms, skipping docs-only and release PRs, the GitHub link, found/changed, and the fallback with no git.
  • Full suite: 3,988 of 3,998 pass. The 2 failures (graft-to-trail, hosts-trail, moving a graft repo to trail) fail the same way on main's code on this machine, so they're unrelated.

The web side (trail-cloud) shows the PR on the card with a link.

🤖 Generated with Claude Code

The onboarding page's token card measured one lookup on the repo's most
central symbol, which read as a demo. It now asks what an agent starting
the last merged PR would ask: the PR's title. git's history on the
default branch names the PR (merge commits and squash merges), skipping
bots, release chores and PRs that changed no product code. The answer is
measured as before (ask's own pack against reading the files whole), and
the summary carries the PR: number, title, GitHub link, up to 20 of the
code files it changed, how many it changed, and how many of those the
answer pointed to. With no such PR the central-symbol lookup is used, as
before.

On trailhq/trail-cloud: PR #25, ~90% fewer tokens, the answer pointed to 1
of its 4 files. On honojs/hono: PR #5405, ~75%, 1 of its 1 file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trailhq-graft

trailhq-graft Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🌱 graft blast radius

1 area changed → 1 area can be affected. 3 dependent symbols, depth 2.
Tests: 1 area updated its tests.
Tag: @anirudhkumar-nanonets — CLI Initialization · Rushabh Nagda — Cloud Onboarding

flowchart TB
  A0(("CLI Initialization<br/>3 symbols"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0 reached;
Loading
Can be affected Symbols Nearest hop Reached from
CLI Initialization 3 src/cli.ts:L1809-L1891 runConnectInit — calls, depth 1 Cloud Onboarding
Who knows this code — 2 people across 2 areas
Area Who knows it
Cloud Onboarding · changed Rushabh Nagda — 3 commits, last 2d ago
CLI Initialization · affected @anirudhkumar-nanonets — 61 commits, last yesterday

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 3 dependent symbols, grouped by area

CLI Initialization — 3 symbols in 1 file

  • src/cli.ts:L1809-L1891 — runConnectInit (calls, depth 1)
    1870: const tokens = tokensOnOneLookup(repo, { contextDir: program.opts<GlobalOpts>().dir });
  • src/cli.ts:L1448-L1798 — runInitCommand (calls, depth 1)
    1644: let tokens: ReturnType<typeof tokensOnOneLookup> = null;
  • src/cli.ts:L1-L2588 — cli.ts (calls, depth 2)
    86: tokensOnOneLookup,
Test signal per changed area — 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.

  • ✓ Cloud Onboarding — 2 of 4 reached · 1 test file changed here: test/trail-connect.test.ts
    • not reached: tokensOnLastPr, tokensDone

graft blast · origin/main...HEAD · depth 2 · 3 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 23, 2026
@shhdwi
shhdwi merged commit 5da5441 into main Oct 23, 2026
8 checks passed
github-actions Bot added a commit that referenced this pull request Oct 23, 2026
@shhdwi shhdwi mentioned this pull request Oct 23, 2026
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