chore(graphstore): collapse the four full-scan edge index builders into one

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start with the four edge index builders: BuildReverseAdjacency and BuildImplementsIndex in internal/query/traverse.go, buildReverseAdjacency in internal/indexer/sync.go, and buildContainsIndex in internal/query/traverse.go. Add one graphstore function that takes the edge kinds to keep, keep the Source sort for implements, and point the call sites at it, including the eight listed in the issue. Done means task test passes and the golden files are unchanged.

Written by the indexing model from the issue text.

Description

area:indexer chore priority:low
What kind of chore?

Repository housekeeping

What needs doing?

Four functions build an in-memory edge map from one full IterateEdges("") scan, keyed by edge.Target:

  • query.BuildReverseAdjacency in internal/query/traverse.go:31 keeps only calls edges.
  • query.BuildImplementsIndex in internal/query/traverse.go:369 keeps only implements edges and sorts each list by Source.
  • buildReverseAdjacency in internal/indexer/sync.go:614 copies the first function. Its comment says the copy exists because an internal/query test import of internal/indexer forms an import cycle.
  • query.buildContainsIndex in internal/query/traverse.go:401 is a fourth full scan. It keeps only contains edges, keys them by edge.Source and folds overload sets into a method-owner map, so it needs a parameter for the key as well as for the kinds.

Add one graphstore function that takes the set of edge kinds to keep. Keep the Source sort for implements, so list order does not change. Point the seam at internal/query/traverse.go:61 and the call sites at the new function. BuildReverseAdjacency has five callers outside the seam (internal/query/seeding.go:186, internal/query/expand.go:486, internal/query/traverse.go:757, 853 and 981). BuildImplementsIndex has three (internal/query/traverse.go:761, 857 and 985).

Run task test before the pull request. Each golden file stays the same.

Why now?

Decision D11 of the bounded-index-memory change (#271) gives the sync copy a set of edge kinds and leaves query unchanged. Task 6.1 then carries a second copy of the same algorithm. Collapsing the functions first means task 6.1 adds the edge-kind parameter to one function. The change's workflow follow-up asks for this issue.

Does this touch anything load-bearing?
  • The release pipeline (release.yml, .goreleaser.yaml, signing)
  • The upgrade identity (internal/upgrade/verify.go)
  • The perf baseline (tools/bench/baseline.json)
  • The graph schema / meta-key layout
  • None of these
Before submitting
  • I searched existing issues and this is not a duplicate

🤖 Generated with Claude Code

https://claude.ai/code/session_01ATb3AjCdy2v381oRkeyVrV

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.