feat: standalone index for a linked worktree

Open
#363 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go

Research direction

Start by reading the worktree-index-fallback proposal and the implementation of codegraph sync, codegraph init, and codegraph githooks install; the issue does not name source files or tests. Reproduce the linked-worktree setup described in the issue, including a main checkout with its MCP server holding the store open. Done means a worktree can get a safe standalone index without a full build, and hook behavior when it has no index is documented or defined.

Written by the indexing model from the issue text.

Description

needs-triage

Problem

A linked worktree borrows the main checkout's index through the worktree-index fallback (v0.19). Queries in the worktree then describe the main checkout's tree, not the worktree's edits. The notice says so, but the answers are still stale. Agents now do most of their work in linked worktrees, for example worktrunk wt worktrees under a shared root. So most agent sessions query a tree that is not theirs.

#119 ("worktree support beyond detect-and-warn") closed as completed. But the worktree-index-fallback proposal still lists "a per-worktree index, automatic init in a worktree, or an index keyed by worktree HEAD" as out of scope.

Request

Give a linked worktree its own index without a full build. Two possible shapes:

  1. A command such as codegraph init --from-main that copies the main checkout's index into the worktree and syncs it to the worktree's tree.
  2. The same step done on its own, the first time codegraph runs in a linked worktree that has no index.

The copy must be safe while the main checkout's MCP server holds the store open and writes to it.

What works today, and its limit

In a linked worktree of a 466-file repository:

cp -R <main>/.codegraph .codegraph
codegraph sync    # reparsed=64 pruned=396, 1.2 s
codegraph status --json | jq .worktreeMismatch    # null

The worktree then has a standalone index. The limit is the copy: cp -R of an open store can capture a write in progress. If the sync fails, the workaround falls back to codegraph index --force.

Related

  • codegraph githooks install keeps an index current between sessions. The hooks live in the common .git/hooks, so they run in every worktree. The docs can state what sync does from a hook in a worktree that has no index of its own: skip in silence, or fail.

🤖 Generated with Claude Code

Dominant language
Go
Stars
0
Forks
0
Avg merge
5h 16m
Merged PRs (30d)
107

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seanb4t/codegraph-go

All issues in seanb4t/codegraph-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.