Repository navigation
fix(retrieval): keep scope_id under node budget; honest scoped truncation; validate depth - #145
Merged
Merged
Conversation
…tion - scope_id is derived per included node from the outgoing links already read in collectEdgesForNodes (before the included-target filter), so truncated and exact-fit project graphs keep scope clustering; no unbounded scope_member scan. - nodes are sorted once on every return path. - scoped mode: truncated only when a candidate is actually dropped; total_entities = included + distinct dropped (lower bound); no lookup for members beyond the budget. - GET /v1/graph mode=project&scope=…: depth must be 1..2 (400 otherwise); OpenAPI depth description updated. Patch produced by the Kilo worker (Nemotron 3 Ultra), independently reviewed.
|
Warning Review limit reachedNext included review available in 40 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: mrchatam/Trace/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Problem (verified on main 908d498)
scope_iddisappears whenever the node budget fills.collectProjectNodesreturns early as soon asmax_nodesis reached. ThememberScopeIndexfill (and the sort) only ran when every entity fit. Probe with 1 scope + 5 member tasks:MaxNodes3/5/6 → 0 nodes carryscope_id; 100 → 5. An exact fit (6 nodes,truncated=false) loses them as well. In practice the GUI's scope clustering never kicks in for projects above the 500 default.memberScopeIndexalso scanned everyscope_memberlink, with no bound.MaxNodes=5returnstruncated=trueeven though nothing was left out. WithMaxNodes=3it returnstruncated=truebuttotal_entities == len(nodes), so the GUI shows 0 omitted.depthinmode=project&scope=…was silently ignored when invalid and silently capped above 2. OpenAPI still said "neighborhood mode only".Fix
collectEdgesForNodesfillsScopeIDfrom the first outgoingscope_member→ scope link it already reads per included node. This happens before the included-target filter, so it still works when the scope node itself falls outside the budget. The project path no longer does a global scan.memberScopeIndexis kept only forNeighborhood, which is unchanged.collectProjectNodeswraps an unsorted collector and sorts once on every path, through a sharedprojectGraphSortLess.lookupEntity, so no extra DB read happens for members that get dropped.truncatedonly reflects real drops.total_entities = len(nodes) + distinct dropped(a lower bound, commented as such).scopeis set,depthmust be an integer 1..2 or the request gets 400 VALIDATION_ERROR. Withoutscope,depthis still ignored, as before, so existing clients keep working. The OpenAPI description is updated.Tests
internal/retrieval/scope_graph_budget_test.go:MaxNodes3/5/6/100: every task node has the scope id. At 3/5 the scope node is excluded, which proves the case that was broken.total=5; budget 3 → truncated withtotal > len(nodes).internal/httpapi/httpapi_test.goTestGraphProjectModeDepthValidation: with scope, depth=abc/3 → 400 and depth=1/2/none → 200. Neighborhood depth=8 still returns 200.The scope_id, truncation and HTTP tests fail on main and pass here.
CGO_ENABLED=1 go test ./...passes locally.Reviewer note (Low, not changed here): in scoped mode, a member dropped in the seeding loop doesn't set
truncateddirectly. It gets set right after, because the depth ≥ 1 walk from the scope node runs into the same dropped members, and the tests cover this. A follow-up could settruncated = len(dropped) > 0explicitly.Patch produced by the Kilo worker (Nemotron 3 Ultra; task
kw-20260926-192624-a6d6) and independently reviewed and tested by the supervisor. It took 2 revisions: the first fixed compile errors, a real bug (ScopeID was assigned after the included filter, which would have kept the bug alive in truncated graphs), the dropped-member lookups, and the depth validation scope. The second removed a leftover duplicate function.@coderabbitai review