codescout
codescout copied to clipboard
Linked worktree: index status reports 0 chunks after a successful build; semantic_search says main was never indexed
Summary
In a linked git worktree that has its own .codescout/project.toml, index(action="build") writes the chunks into the worktree delta store (<main>@<wt> → <main>_<wt>.db). But:
index(action="status")keeps reportingindexed: false, 0 chunks after the build finishes. It appears to read the worktree's own project id (<main>-<wt>from itsproject.toml), whose.dbstays empty.semantic_searchin that worktree returns the delta results (so the index works), but addsmain_never_indexed_note: "Main project <main> has no indexed chunks yet", although the main checkout is fully indexed. It seems to open an empty<main>.dbcreated under the worktree's.codescout/embeddings/, not the main checkout's store.
So the build works. The status reporting is wrong, and it is possible that main's chunks are never served to queries from the worktree.
Environment
- codescout 0.15.0 (
~/.cargo/bin/codescout) - Linux 7.0 (x86_64); embeddings:
nomic-ai/CodeRankEmbed(768d) through a local TEI server (text-embeddings-router,url = http://127.0.0.1:<port>/v1) on a GTX 1660 Ti; sqlite-vec store - Claude Code with codescout-companion; plugins updated the same day; automatic index refresh at SessionStart active (the main checkout was refreshed at session start: "INDEX: Refreshing in background (18 commits behind HEAD)")
Layout (names anonymised)
~/work/proj main checkout [main]
~/work/proj/.worktrees/wt linked worktree [feature-branch]
- Main
.codescout/project.toml:name = "proj",languages = ["markdown"](docs only) - Worktree
.codescout/project.toml(created earlier by a separate onboarding inside the worktree):name = "proj-wt",languages = ["python","javascript","markdown"]; same[embeddings]model/url - The session was started in the main checkout. The build was run with a per-call pin:
index(action="build", workspace="<abs path to worktree>"). Noworkspace(activate)on the worktree.
Steps and observations
index(action="status", workspace=<main>)→indexed: true,file_count: 5,chunk_count: 454,git_sync: up_to_date.verify→complete.index(action="status", workspace=<wt>)→indexed: false,project_id: "proj-wt", "No chunks indexed for project 'proj-wt'".index(action="build", workspace=<wt>)→started.- During the build (~12.5 min),
statusshowedstatus: running, done: 0, total: 0, chunks_so_far: 0the whole time. The note says "chunk_count climbs from 0 on an initial build", but it never climbed. Meanwhile, read-only on disk:<wt>/.codescout/embeddings/proj_wt.dbgrew 13.6 MB → 26.2 MB;select count(*) from code_chunk= 3072 mid-build, 5146 at the end;select distinct project_id from code_chunk=proj@wt- so the build is clearly writing the delta id
delta_project_id(main, wt)=proj@wt, sanitized toproj_wt.db(sanitize_db_namemaps@→_)
- After the build:
status→indexing: { status: "done", files_indexed: 5146, detail: "elapsed_ms=751161 delta_chunks=5146 dirty_paths=221", total_files: 0, total_chunks: 0 }, and stillindexed: false, "No chunks indexed for project 'proj-wt'".- Minor:
files_indexed: 5146is the chunk count; the file count isdirty_paths=221.
- Minor:
semantic_search(query=..., workspace=<wt>)→ correct, relevant results from the worktree code (served from the delta), plusmain_never_indexed_note: "Main project 'proj' has no indexed chunks yet. Results below come only from this worktree's delta -- main's own code is not represented."
Store files after the build (read-only sqlite3 -readonly)
| File | code_chunk rows |
Note |
|---|---|---|
<main>/.codescout/embeddings/proj.db |
454 | the real main index |
<wt>/.codescout/embeddings/proj.db |
0 | 16 KB, created at the moment the build started |
<wt>/.codescout/embeddings/proj-wt.db |
0 | 16 KB, from the earlier onboarding in the worktree |
<wt>/.codescout/embeddings/proj_wt.db |
5146 | delta store, project_id = 'proj@wt' |
Expected
statuson the worktree reports the delta chunks (or main + delta), and progress climbs during the build.semantic_searchfrom the worktree finds main's store in the main checkout (<main>/.codescout/embeddings/) and serves main + delta; no "never indexed" note when main is indexed.files_indexedreports files, not chunks.
Suspected cause (from reading the source, unverified)
retrieval/sync.rs::delta_project_id→"{main}@{wt}";sqlite_vec_ext.rs::sanitize_db_nameturns@into_→proj_wt.db.- The status/
indexedcheck seems to use the worktree's ownproject.tomlname (proj-wt) and not the delta id, so it opensproj-wt.db(empty). - The main-store lookup from the worktree seems to resolve the embeddings dir relative to the worktree root (
<wt>/.codescout/embeddings/proj.db, opened empty and created on first use), not the main checkout's root. This is also the likely reason main's chunks are never served from the worktree. - A worktree carrying its own
project.tomlwith a differentnamemay be the trigger. I don't know whether a worktree without its ownproject.tomlbehaves correctly.
Impact
- Users (and agents) are told the worktree is not indexed when it is, which invites needless rebuilds. The session-start reminder had to say "trust
semantic_search, notstatus". - Queries from a worktree probably miss everything the main checkout contributes. Here main is docs-only, so the impact was small, but in a repo where main holds most of the code it would be large and silent.
Happy to run more read-only diagnostics if useful.