Skip to content

Commit 134f875

Browse files
committed
fix: configuration inheritance and boolean merging
1 parent 60ce224 commit 134f875

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

internal/core/config/config.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type EmbeddingConfig struct {
6161
type DefaultsConfig struct {
6262
SimilarityThreshold float64 `yaml:"similarity_threshold"`
6363
MaxSimilarToShow int `yaml:"max_similar_to_show"`
64-
CrossRepoSearch bool `yaml:"cross_repo_search"`
64+
CrossRepoSearch *bool `yaml:"cross_repo_search,omitempty"`
6565
}
6666

6767
// RepositoryConfig defines a repository and its settings.
@@ -88,9 +88,9 @@ type TransferRule struct {
8888

8989
// TransferConfig holds transfer routing settings.
9090
type TransferConfig struct {
91-
Enabled bool `yaml:"enabled"`
91+
Enabled *bool `yaml:"enabled,omitempty"`
9292
Rules []TransferRule `yaml:"rules,omitempty"`
93-
LLMRoutingEnabled bool `yaml:"llm_routing_enabled,omitempty"`
93+
LLMRoutingEnabled *bool `yaml:"llm_routing_enabled,omitempty"`
9494
HighConfidence float64 `yaml:"high_confidence,omitempty"` // Default: 0.9
9595
MediumConfidence float64 `yaml:"medium_confidence,omitempty"` // Default: 0.6
9696
DuplicateConfidenceThreshold float64 `yaml:"duplicate_confidence_threshold,omitempty"` // Default: 0.8
@@ -183,13 +183,25 @@ func (c *Config) applyDefaults() {
183183
if c.Defaults.MaxSimilarToShow == 0 {
184184
c.Defaults.MaxSimilarToShow = 5
185185
}
186+
if c.Defaults.CrossRepoSearch == nil {
187+
f := false
188+
c.Defaults.CrossRepoSearch = &f
189+
}
186190
if c.Embedding.Provider == "" {
187191
c.Embedding.Provider = "gemini"
188192
}
189193
if c.Embedding.Dimensions == 0 {
190194
c.Embedding.Dimensions = 768
191195
}
192-
// Transfer LLM routing defaults
196+
// Transfer defaults
197+
if c.Transfer.Enabled == nil {
198+
f := false
199+
c.Transfer.Enabled = &f
200+
}
201+
if c.Transfer.LLMRoutingEnabled == nil {
202+
f := false
203+
c.Transfer.LLMRoutingEnabled = &f
204+
}
193205
if c.Transfer.HighConfidence == 0 {
194206
c.Transfer.HighConfidence = 0.9
195207
}
@@ -243,18 +255,22 @@ func mergeConfigs(parent, child *Config) *Config {
243255
if child.Defaults.MaxSimilarToShow != 0 {
244256
result.Defaults.MaxSimilarToShow = child.Defaults.MaxSimilarToShow
245257
}
246-
// CrossRepoSearch: always take the child value so it can override parent true -> false and vice versa
247-
result.Defaults.CrossRepoSearch = child.Defaults.CrossRepoSearch
258+
if child.Defaults.CrossRepoSearch != nil {
259+
result.Defaults.CrossRepoSearch = child.Defaults.CrossRepoSearch
260+
}
248261

249262
// Repositories: child completely overrides if non-empty
250263
if len(child.Repositories) > 0 {
251264
result.Repositories = child.Repositories
252265
}
253266

254-
// Transfer.Enabled: always take the child value so it can override parent true -> false and vice versa
255-
result.Transfer.Enabled = child.Transfer.Enabled
256-
result.Transfer.LLMRoutingEnabled = child.Transfer.LLMRoutingEnabled
257-
// Transfer.Rules: child overrides rules if non-empty; otherwise inherit from parent
267+
// Transfer: override if fields are set
268+
if child.Transfer.Enabled != nil {
269+
result.Transfer.Enabled = child.Transfer.Enabled
270+
}
271+
if child.Transfer.LLMRoutingEnabled != nil {
272+
result.Transfer.LLMRoutingEnabled = child.Transfer.LLMRoutingEnabled
273+
}
258274
if len(child.Transfer.Rules) > 0 {
259275
result.Transfer.Rules = child.Transfer.Rules
260276
}

internal/steps/llm_router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (s *LLMRouter) Name() string {
3333
// Run analyzes issue and routes to best repository.
3434
func (s *LLMRouter) Run(ctx *pipeline.Context) error {
3535
// Skip if LLM routing is disabled or no LLM client
36-
if !ctx.Config.Transfer.LLMRoutingEnabled || s.llm == nil {
36+
if ctx.Config.Transfer.LLMRoutingEnabled == nil || !*ctx.Config.Transfer.LLMRoutingEnabled || s.llm == nil {
3737
log.Printf("[llm_router] LLM routing disabled or no client, skipping")
3838
return nil
3939
}

internal/steps/similarity.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func (s *SimilaritySearch) Run(ctx *pipeline.Context) error {
4747
threshold := ctx.Config.Defaults.SimilarityThreshold
4848
limit := ctx.Config.Defaults.MaxSimilarToShow
4949

50+
// Cross-repo search logic could be added here if needed, but current implementation
51+
// depends on the collection containing all org issues.
52+
5053
// Skip if dependencies are missing (e.g. testing mode)
5154
if s.embedder == nil || s.store == nil {
5255
log.Printf("[similarity_search] WARNING: Dependencies missing, skipping search")

internal/steps/transfer_check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (s *TransferCheck) Name() string {
2929
// Run checks if the issue should be transferred using transfer rules.
3030
func (s *TransferCheck) Run(ctx *pipeline.Context) error {
3131
// Skip if transfer is not enabled or no rules configured
32-
if !ctx.Config.Transfer.Enabled || len(ctx.Config.Transfer.Rules) == 0 {
32+
if ctx.Config.Transfer.Enabled == nil || !*ctx.Config.Transfer.Enabled || len(ctx.Config.Transfer.Rules) == 0 {
3333
log.Printf("[transfer_check] Transfer not enabled or no rules, skipping")
3434
return nil
3535
}

0 commit comments

Comments
 (0)