Skip to content

Make max_distance configurable via RepositoryConfig#95

Merged
yushan8 merged 4 commits into
mainfrom
distance-trim
May 29, 2026
Merged

Make max_distance configurable via RepositoryConfig#95
yushan8 merged 4 commits into
mainfrom
distance-trim

Conversation

@yushan8
Copy link
Copy Markdown
Contributor

@yushan8 yushan8 commented May 29, 2026

Summary

Adds a server-side default for BFS distance trimming so operators can cap which changed targets are returned without requiring every client to set output_config.max_distance.

What changed

config.RepositoryConfig — new max_distance field (YAML: max_distance). 0 means unset; positive values enable distance trimming at that depth.

config.RepositoryConfigProvider — new interface with a single GetRepositoryConfig(remote string) (RepositoryConfig, bool) method. *config.Config implements it
(verified by a compile-time check). Future implementations (e.g. a remote config service) can be swapped in without touching the controller.

controller — the controller now accepts a RepositoryConfigProvider (optional, safe when nil) instead of *config.Config directly. A new resolveMaxDistance function
merges the two sources with clear priority:

  1. Client wins: if output_config.compute_distances is true, use output_config.max_distance (any value, including 0 = direct-only).
  2. Server default: if the repo config has max_distance > 0, use it — this enables distance trimming even when the client doesn't request it.
  3. Neither set: no distance trimming (-1).

The resolved maxDist is computed once per request and threaded through compareTargetGraphs, compareTargetGraphsAndEdges, sendWithDistanceFilter, and
sendWithDistanceFilterForEdges, which now take int32 maxDist directly instead of *pb.OutputConfig.

Test plan

  • Added TestResolveMaxDistance covering all priority cases (client overrides server, server default applied, neither set, max_distance=0 treated as unset in repo
    config)
  • All existing controller tests updated and passing (bazel test //...)

@yushan8 yushan8 requested review from a team as code owners May 29, 2026 20:26
@yushan8 yushan8 changed the title Add max_distance to RepositoryConfig Make max_distance configurable via RepositoryConfig May 29, 2026
@yushan8 yushan8 merged commit 40c7d2b into main May 29, 2026
6 checks passed
@yushan8 yushan8 deleted the distance-trim branch May 29, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants