docs: correct the codegraph mechanism — it was inferred, not checked - #64
Merged
Merged
Conversation
Update 5 claimed codegraph's root detection "wants a `.git` directory", and that the bare-worktree layout — where a worktree's `.git` is a file — was therefore the cause of the stray ancestor index. That was inferred from the symptom (it happened in a worktree) and never checked against the source. `resolveProjectPath` and `findNearestCodeGraphRoot` do not consult `.git` at all. They look only for an initialized `.codegraph`, with no repo boundary to stop at. `index <path>` discards its argument whenever that path is not itself initialized, walks up to the filesystem root, and rebuilds the first initialized ANCESTOR — printing an ordinary `Done` and never naming what it indexed. Falsified by reproducing it with no git repository anywhere: initialize a parent, run `codegraph index .` from an un-indexed child, and it reports success while creating no index in the child and rebuilding the parent's. The worktree layout is an aggravating condition, not the cause — sibling worktrees are never initialized themselves, so the walk escapes the repo on the first `index` in a fresh one. Any un-indexed subdirectory does it. The practical guidance (`init`, not `index`) was right for the wrong reason, which is the failure mode this document names everywhere else: a correct answer whose stated justification does not survive being checked. Verified against upstream tip d6d1728 = the installed 1.5.0, so this describes current code rather than a version I happened to have. Reported upstream as colbymchenry/codegraph#1524. Also records that the OTHER codegraph finding — no call resolution through an aliased module binding — was already known upstream: issue #899, open PR #1453, whose diagnosis matches the measured table exactly (the submodule lookup joins the import source with `imp.localName`, which under an alias names no module). Confirmed on that PR with a five-file minimal repro. Checked before filing: all 618 issues and 881 PRs pulled and grepped locally, body search validated against a control query, and every open PR touching the resolver diffed — 4 add calls to it, none modifies it. 251 tests, unchanged by this diff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update 5 (merged an hour ago in #59) gave the wrong cause for the stray-ancestor-index behaviour. This corrects it, and records the upstream status of both codegraph findings now that they have been checked.
What was wrong
resolveProjectPathandfindNearestCodeGraphRootdo not consult.gitat all. They look only for an initialized.codegraph, with no repo boundary to stop at:I inferred
.gitfrom the symptom — it happened in a worktree — and never checked the source.How it was falsified
Reproduced with no git repository anywhere:
The worktree layout is an aggravating condition, not the cause: sibling worktrees are never initialized themselves, so the walk escapes the repo on the first
indexin a fresh one. Any un-indexed subdirectory does it.The practical guidance was unaffected —
initfor a first index, neverindex— which is the uncomfortable part. It was right for the wrong reason, the exact failure mode this document names everywhere else: a correct answer whose stated justification does not survive being checked. Verified against upstream tipd6d1728, which is the installed 1.5.0, so this describes current code rather than whatever version happened to be lying around.Reported upstream: colbymchenry/codegraph#1524.
The other finding was already reported
The aliased-module call-resolution bug is not new — upstream issue #899, with open PR #1453 carrying a fix. Its diagnosis matches the measured table exactly: the submodule lookup joins the import source with
imp.localName, which under an alias names no module, andlocalNamecoincides withexportedNameonly when the import is unaliased.I confirmed it on that PR with a five-file minimal repro — the PR's own description says it "reproduces in real trees but not in minimal repros", which turns out to be true only at the
callslevel; the file→fileimportshalf reproduces in five files. Two modules identical apart from the alias:Nothing to do here but wait and re-measure. The registry declaration in
journeys/testgraph.jsonstands until then.Verification before filing
Since a tracker search proves nothing about fix-state:
d6d1728(v1.5.0 = installed)gh searchresolveProjectPathgenuinely empty)src/bin/codegraph.ts/src/directory.ts— 4 only add calls to the resolver, none modifies itThat last check is the one that mattered: it is what separates "nobody has reported it" from "a fix is already in flight", and it is the check that found #1453 for the other bug.
Verification
251 tests, unchanged by this diff (documentation only).