Skip to content

fix(claude): inject a pre-rename INDEX.md preamble in the running name - #771

Open
minjunkim-dev wants to merge 2 commits into
trailhq:mainfrom
minjunkim-dev:fix/rebrand-stale-index-preamble
Open

minjunkim-dev wants to merge 2 commits into
trailhq:mainfrom
minjunkim-dev:fix/rebrand-stale-index-preamble

Conversation

@minjunkim-dev

@minjunkim-dev minjunkim-dev commented Nov 8, 2026 •

Copy link
Copy Markdown

Summary

Fixes #770.

A graft/INDEX.md built before the rename stays on disk until the next full build, because query-path refreshes run with graphOnly and skip writeIndex. Session start pasted the file in as it is. So under trail, the agent got graft ask, graft callers and graft_find_code, right below a directive that correctly says trail ask, and none of the graft names exist on a trail-only machine.

Changes

  • src/claude/format.ts: formatOrientation now runs INDEX.md's preamble (everything before the first ## section) through inBrand() before injecting it. This is the same transform writeIndex already applies to that preamble.
    • A fresh INDEX.md comes out unchanged.
    • Under graft, inBrand returns its input, so graft's output stays byte for byte the same.
    • The concept and file lists are not rewritten, so a repo's own concept named "graft" keeps its name.
  • test/claude-orientation-brand.test.ts: a new file, so the brand env var it sets stays in its own process.
    • Under trail, a graft-era INDEX.md is injected with trail names, and its concept list is left as is.
    • Under trail, an INDEX.md that a trail build wrote is injected unchanged.
    • Under graft, it is injected byte for byte.

The file on disk is not touched. The next full trail build rewrites it, as before. #371 tracks the broader problem of cards going stale between full builds.

Testing

  • End to end, through the real hook.
    • In a throwaway repo, I built a map with the graft-branded CLI (node dist/cli.js build . with TRAIL_INVOKED_AS unset). That wrote # graft — repo map with graft ask and graft_find_code.
    • I then ran main('session-start') from src/claude/hooks.ts with TRAIL_INVOKED_AS=trail, a temporary HOME, and a SessionStart payload on stdin.
    • With the 0.29.0 release, the repo map (graft/INDEX.md): block contained graft ask and graft_find_code, right under the reach for trail first directive.
    • With this branch's build, it contained trail ask and trail_find_code, with no graft names. graft/INDEX.md on disk was left as it was.
  • The new test file fails on main and passes on this branch.
  • The new file passes together with test/claude-format.test.ts and test/claude-copy-dashes.test.ts (31 of 31).
  • tsc -p tsconfig.json --noEmit is clean.
  • Full npm test on macOS (Node 26.13.0): 28 failures on this branch and 29 on main at e02b754, with the same tests failing on both. They are in init/skills/hooks tests and look environmental here. The only test that failed on this branch alone was test/hooks-fifo.test.ts, under full-suite load. It passed 3 of 3 runs on its own.
  • Tests run with TRAIL_INVOKED_AS unset. If a shell has it set to trail, as a Claude Code session started by trail does, the existing graft-spelled assertions in claude-format.test.ts fail, on main too.

🤖 Generated with Claude Code

A graft/INDEX.md built before the rename stays on disk until the next full
build, since query-path refreshes skip writeIndex. Session start pasted it
verbatim, so under trail it taught graft ask and graft_* tools that a
trail-only machine does not have. Run the preamble through inBrand at
injection, the same transform writeIndex uses; concept and file lists keep
the repo's own words, and graft output is unchanged.

Fixes trailhq#770

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

1 area changed → 1 area can be affected. 2 dependent symbols, depth 2.
Tests: 1 area updated its tests.
Tag: @anirudhkumar-nanonets — Orientation Formatting, Orientation Management · @shhdwi — Orientation Formatting, Orientation Management

flowchart TB
  A0(("Orientation Management<br/>2 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
Orientation Management 2 src/claude/hooks.ts:L505-L515 orientationAtStart — calls, depth 1 Orientation Formatting
Who knows this code — 2 people across 2 areas
Area Who knows it
Orientation Formatting · changed @anirudhkumar-nanonets — 4 commits, last today · @shhdwi — 2 commits, last 12d ago
Orientation Management · affected @anirudhkumar-nanonets — 7 commits, last today · @shhdwi — 2 commits, last 12d ago

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

Orientation Management — 2 symbols in 1 file

  • src/claude/hooks.ts:L505-L515 — orientationAtStart (calls, depth 1)
  • src/claude/hooks.ts:L526-L616 — main (calls, depth 2)
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.

  • ✓ Orientation Formatting — 1 of 2 reached · 1 test file changed here: test/claude-orientation-brand.test.ts
    • not reached: indexInBrand
3 test suites also reference this code

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

  • test/claude-copy-dashes.test.ts
  • test/claude-format.test.ts
  • test/trail-notes.test.ts

graft blast · refs/graft/base...HEAD · depth 2 · 2 changed files

Open the interactive graph → — click an area to see the code that changed, and the line that reaches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@minjunkim-dev
minjunkim-dev marked this pull request as ready for review November 8, 2026 13:36

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.

Session start injects a pre-rename graft/INDEX.md that teaches graft commands on a trail-only machine

1 participant