11// Copyright (c) Microsoft. All rights reserved.
22using System . Text . Json . Serialization ;
33using KernelMemory . Core . Config . Validation ;
4- using KernelMemory . Core . Search ;
54
65namespace KernelMemory . Core . Config ;
76
@@ -17,22 +16,22 @@ public sealed class SearchConfig : IValidatable
1716 /// Default: 0.3 (moderate threshold).
1817 /// </summary>
1918 [ JsonPropertyName ( "defaultMinRelevance" ) ]
20- public float DefaultMinRelevance { get ; set ; } = SearchConstants . DefaultMinRelevance ;
19+ public float DefaultMinRelevance { get ; set ; } = Constants . SearchDefaults . DefaultMinRelevance ;
2120
2221 /// <summary>
2322 /// Default maximum number of results to return per search.
2423 /// Default: 20 results.
2524 /// </summary>
2625 [ JsonPropertyName ( "defaultLimit" ) ]
27- public int DefaultLimit { get ; set ; } = SearchConstants . DefaultLimit ;
26+ public int DefaultLimit { get ; set ; } = Constants . SearchDefaults . DefaultLimit ;
2827
2928 /// <summary>
3029 /// Search timeout in seconds per node.
3130 /// If a node takes longer than this, it times out and is excluded from results.
3231 /// Default: 30 seconds.
3332 /// </summary>
3433 [ JsonPropertyName ( "searchTimeoutSeconds" ) ]
35- public int SearchTimeoutSeconds { get ; set ; } = SearchConstants . DefaultSearchTimeoutSeconds ;
34+ public int SearchTimeoutSeconds { get ; set ; } = Constants . SearchDefaults . DefaultSearchTimeoutSeconds ;
3635
3736 /// <summary>
3837 /// Default maximum results to retrieve from each node (memory safety).
@@ -41,7 +40,7 @@ public sealed class SearchConfig : IValidatable
4140 /// Default: 1000 results per node.
4241 /// </summary>
4342 [ JsonPropertyName ( "maxResultsPerNode" ) ]
44- public int MaxResultsPerNode { get ; set ; } = SearchConstants . DefaultMaxResultsPerNode ;
43+ public int MaxResultsPerNode { get ; set ; } = Constants . SearchDefaults . DefaultMaxResultsPerNode ;
4544
4645 /// <summary>
4746 /// Default nodes to search when no explicit --nodes flag is provided.
@@ -50,7 +49,7 @@ public sealed class SearchConfig : IValidatable
5049 /// </summary>
5150 [ JsonPropertyName ( "defaultNodes" ) ]
5251 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Performance" , "CA1819:Properties should not return arrays" ) ]
53- public string [ ] DefaultNodes { get ; set ; } = [ SearchConstants . AllNodesWildcard ] ;
52+ public string [ ] DefaultNodes { get ; set ; } = [ Constants . SearchDefaults . AllNodesWildcard ] ;
5453
5554 /// <summary>
5655 /// Nodes to exclude from search by default.
@@ -67,66 +66,66 @@ public sealed class SearchConfig : IValidatable
6766 /// Default: 10 levels.
6867 /// </summary>
6968 [ JsonPropertyName ( "maxQueryDepth" ) ]
70- public int MaxQueryDepth { get ; set ; } = SearchConstants . MaxQueryDepth ;
69+ public int MaxQueryDepth { get ; set ; } = Constants . SearchDefaults . MaxQueryDepth ;
7170
7271 /// <summary>
7372 /// Maximum number of boolean operators (AND/OR/NOT) in a single query.
7473 /// Prevents query complexity attacks.
7574 /// Default: 50 operators.
7675 /// </summary>
7776 [ JsonPropertyName ( "maxBooleanOperators" ) ]
78- public int MaxBooleanOperators { get ; set ; } = SearchConstants . MaxBooleanOperators ;
77+ public int MaxBooleanOperators { get ; set ; } = Constants . SearchDefaults . MaxBooleanOperators ;
7978
8079 /// <summary>
8180 /// Maximum length of a field value in query (characters).
8281 /// Prevents oversized query values.
8382 /// Default: 1000 characters.
8483 /// </summary>
8584 [ JsonPropertyName ( "maxFieldValueLength" ) ]
86- public int MaxFieldValueLength { get ; set ; } = SearchConstants . MaxFieldValueLength ;
85+ public int MaxFieldValueLength { get ; set ; } = Constants . SearchDefaults . MaxFieldValueLength ;
8786
8887 /// <summary>
8988 /// Maximum time allowed for query parsing (milliseconds).
9089 /// Prevents regex catastrophic backtracking.
9190 /// Default: 1000ms (1 second).
9291 /// </summary>
9392 [ JsonPropertyName ( "queryParseTimeoutMs" ) ]
94- public int QueryParseTimeoutMs { get ; set ; } = SearchConstants . QueryParseTimeoutMs ;
93+ public int QueryParseTimeoutMs { get ; set ; } = Constants . SearchDefaults . QueryParseTimeoutMs ;
9594
9695 /// <summary>
9796 /// Default snippet length in characters when --snippet flag is used.
9897 /// Default: 200 characters.
9998 /// </summary>
10099 [ JsonPropertyName ( "snippetLength" ) ]
101- public int SnippetLength { get ; set ; } = SearchConstants . DefaultSnippetLength ;
100+ public int SnippetLength { get ; set ; } = Constants . SearchDefaults . DefaultSnippetLength ;
102101
103102 /// <summary>
104103 /// Default maximum number of snippets per result when --snippet flag is used.
105104 /// Default: 1 snippet.
106105 /// </summary>
107106 [ JsonPropertyName ( "maxSnippetsPerResult" ) ]
108- public int MaxSnippetsPerResult { get ; set ; } = SearchConstants . DefaultMaxSnippetsPerResult ;
107+ public int MaxSnippetsPerResult { get ; set ; } = Constants . SearchDefaults . DefaultMaxSnippetsPerResult ;
109108
110109 /// <summary>
111110 /// Separator string between multiple snippets.
112111 /// Default: "..." (ellipsis).
113112 /// </summary>
114113 [ JsonPropertyName ( "snippetSeparator" ) ]
115- public string SnippetSeparator { get ; set ; } = SearchConstants . DefaultSnippetSeparator ;
114+ public string SnippetSeparator { get ; set ; } = Constants . SearchDefaults . DefaultSnippetSeparator ;
116115
117116 /// <summary>
118117 /// Prefix marker for highlighting matched terms.
119118 /// Default: "<mark>" (HTML-style).
120119 /// </summary>
121120 [ JsonPropertyName ( "highlightPrefix" ) ]
122- public string HighlightPrefix { get ; set ; } = SearchConstants . DefaultHighlightPrefix ;
121+ public string HighlightPrefix { get ; set ; } = Constants . SearchDefaults . DefaultHighlightPrefix ;
123122
124123 /// <summary>
125124 /// Suffix marker for highlighting matched terms.
126125 /// Default: "</mark>" (HTML-style).
127126 /// </summary>
128127 [ JsonPropertyName ( "highlightSuffix" ) ]
129- public string HighlightSuffix { get ; set ; } = SearchConstants . DefaultHighlightSuffix ;
128+ public string HighlightSuffix { get ; set ; } = Constants . SearchDefaults . DefaultHighlightSuffix ;
130129
131130 /// <summary>
132131 /// Validates the search configuration.
@@ -135,10 +134,10 @@ public sealed class SearchConfig : IValidatable
135134 public void Validate ( string path )
136135 {
137136 // Validate min relevance score
138- if ( this . DefaultMinRelevance < SearchConstants . MinRelevanceScore || this . DefaultMinRelevance > SearchConstants . MaxRelevanceScore )
137+ if ( this . DefaultMinRelevance < Constants . SearchDefaults . MinRelevanceScore || this . DefaultMinRelevance > Constants . SearchDefaults . MaxRelevanceScore )
139138 {
140139 throw new ConfigException ( $ "{ path } .DefaultMinRelevance",
141- $ "Must be between { SearchConstants . MinRelevanceScore } and { SearchConstants . MaxRelevanceScore } ") ;
140+ $ "Must be between { Constants . SearchDefaults . MinRelevanceScore } and { Constants . SearchDefaults . MaxRelevanceScore } ") ;
142141 }
143142
144143 // Validate default limit
@@ -167,7 +166,7 @@ public void Validate(string path)
167166 }
168167
169168 // Validate no contradictory node configuration
170- if ( this . DefaultNodes . Length == 1 && this . DefaultNodes [ 0 ] == SearchConstants . AllNodesWildcard )
169+ if ( this . DefaultNodes . Length == 1 && this . DefaultNodes [ 0 ] == Constants . SearchDefaults . AllNodesWildcard )
171170 {
172171 // Using wildcard - excludeNodes is OK
173172 }
0 commit comments