refactor(detekt): extract magic-number constants, wrap long lines, drop legit suppressions
Mechanical detekt cleanup across apps/core/infrastructure (behavior-preserving): - MagicNumber 62->10: named constants + removed 'legit' MagicNumber suppressions (Tier level from ordinal, ReplayInferenceProvider CHARS_PER_TOKEN, ConfigLoader DEFAULT_* consts, capability scores, HTTP ranges, column widths, etc.) - MaxLineLength cut to ~0 in production modules (line wraps, no logic change) - Dropped one dead parameter (ConfigLoader.parseArray lineNum) Structural findings (ReturnCount/LongMethod/Complexity/LargeClass) left for a deliberate decomposition pass. Full build + detekt gate green.
This commit is contained in:
@@ -108,6 +108,9 @@ class DefaultTalkieContextBuilder(
|
||||
|
||||
/** Cap on ideas folded into router context, newest-first, so the board can't balloon L0. */
|
||||
private const val MAX_IDEAS_IN_CONTEXT = 10
|
||||
|
||||
/** Rough chars-per-token heuristic used when no tokenizer is available. */
|
||||
private const val CHARS_PER_TOKEN_ESTIMATE = 4
|
||||
}
|
||||
|
||||
override suspend fun build(
|
||||
@@ -389,7 +392,7 @@ class DefaultTalkieContextBuilder(
|
||||
}
|
||||
|
||||
private fun fallbackEstimate(content: String): Int {
|
||||
return (content.length / 4).coerceAtLeast(1)
|
||||
return (content.length / CHARS_PER_TOKEN_ESTIMATE).coerceAtLeast(1)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,7 +146,12 @@ class DefaultTalkieFacade(
|
||||
// Rebuild state so lastRetrievedMemory reflects this turn
|
||||
state = routerRepository.getTalkieState(sessionId)
|
||||
|
||||
val contextPack = routerContextBuilder.build(state, config.tokenBudget, workflowSummaryProvider(), sessionProfileProvider(sessionId))
|
||||
val contextPack = routerContextBuilder.build(
|
||||
state,
|
||||
config.tokenBudget,
|
||||
workflowSummaryProvider(),
|
||||
sessionProfileProvider(sessionId),
|
||||
)
|
||||
|
||||
if (contextPack.compressionMetadata.entriesDropped > 0) {
|
||||
val truncNow = Clock.System.now()
|
||||
@@ -195,7 +200,8 @@ class DefaultTalkieFacade(
|
||||
"without producing an answer (likely spent on hidden reasoning). " +
|
||||
"Raise [router.generation] max_tokens or lower the model's reasoning budget, then ask again."
|
||||
} else {
|
||||
"The model returned an empty response (finish reason: ${inferenceResponse.finishReason::class.simpleName}). Try again."
|
||||
"The model returned an empty response " +
|
||||
"(finish reason: ${inferenceResponse.finishReason::class.simpleName}). Try again."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user