fix(chunker): QA audit — pointer DTOs, profile reuse, stats correctness
Resolves the issues surfaced by the post-Phase-3 self-review. High severity - Strategy / TokenLimit / Languages can now be reset. The KB-config handler uses pointer DTOs so the absence of a field in the payload means "no change" while an explicit empty string / 0 / [] clears the value. The frontend now sends the fields unconditionally so the user can revert to defaults via the clear icon — previously these fields were write-once. - DocProfile is no longer computed twice in the preview endpoint. Diagnostics carries the profile that drove tier selection (when auto-strategy ran); the handler only re-profiles for explicit strategies that bypass the profiler. - Chunk-size stats (avg / min / max / stddev) are now computed over the FULL chunk set before the response is truncated to previewMaxChunks. Avoids systematically misleading metrics for large documents. - SplitWithDiagnostics defaults SelectedTier to TierLegacy so an empty-text request never leaves the diag with a blank tier string. Medium severity - Split() reverts to its own loop instead of delegating to SplitWithDiagnostics. Diagnostics struct allocation is reserved for callers that actually want the trace (preview endpoint). Matters in SplitParentChild where Split runs once per parent. - Preview endpoint runs the splitter on a goroutine wrapped in a 5s context.WithTimeout. CJK input at the 256k-rune ceiling could otherwise tie up the worker for several seconds. Low severity - KBChunkingSettings emits arrays via spread copies so parent-side mutation cannot drift the form's reactive state. - KBChunkingDebug font-family includes a monospace fallback so the chunk content stays monospaced even when the TDesign CSS variable is missing. Documentation - DocProfile JSON shape is now annotated as part of the public preview API; field renames would be breaking. https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
This commit is contained in:
@@ -849,17 +849,12 @@ const buildSubmitData = () => {
|
||||
enable_parent_child: formData.value.chunkingConfig.enableParentChild,
|
||||
parent_chunk_size: formData.value.chunkingConfig.parentChunkSize,
|
||||
child_chunk_size: formData.value.chunkingConfig.childChunkSize,
|
||||
// Adaptive chunking fields. Empty/zero values are omitted on the
|
||||
// backend side via omitempty; we send them through unconditionally.
|
||||
...(formData.value.chunkingConfig.strategy
|
||||
? { strategy: formData.value.chunkingConfig.strategy }
|
||||
: {}),
|
||||
...(formData.value.chunkingConfig.tokenLimit
|
||||
? { token_limit: formData.value.chunkingConfig.tokenLimit }
|
||||
: {}),
|
||||
...(formData.value.chunkingConfig.languages?.length
|
||||
? { languages: formData.value.chunkingConfig.languages }
|
||||
: {}),
|
||||
// Adaptive chunking fields are always sent (empty/zero values
|
||||
// included) so the user can clear them — backend uses pointer DTOs
|
||||
// to distinguish "not in payload" from "explicitly empty".
|
||||
strategy: formData.value.chunkingConfig.strategy ?? '',
|
||||
token_limit: formData.value.chunkingConfig.tokenLimit ?? 0,
|
||||
languages: formData.value.chunkingConfig.languages ?? [],
|
||||
...(formData.value.chunkingConfig.parserEngineRules?.length
|
||||
? { parser_engine_rules: formData.value.chunkingConfig.parserEngineRules }
|
||||
: {})
|
||||
@@ -1044,10 +1039,12 @@ const doSubmit = async () => {
|
||||
enableParentChild: data.chunking_config.enable_parent_child || false,
|
||||
parentChunkSize: data.chunking_config.parent_chunk_size || 4096,
|
||||
childChunkSize: data.chunking_config.child_chunk_size || 384,
|
||||
// Adaptive chunking — empty / 0 / [] means "leave server default".
|
||||
strategy: data.chunking_config.strategy || undefined,
|
||||
tokenLimit: data.chunking_config.token_limit || undefined,
|
||||
languages: data.chunking_config.languages?.length ? data.chunking_config.languages : undefined
|
||||
// Always send strategy / tokenLimit / languages — backend treats
|
||||
// empty/0/[] as a valid clear, so we must include them in the
|
||||
// payload to let users reset back to defaults.
|
||||
strategy: formData.value?.chunkingConfig.strategy ?? '',
|
||||
tokenLimit: formData.value?.chunkingConfig.tokenLimit ?? 0,
|
||||
languages: formData.value?.chunkingConfig.languages ?? []
|
||||
},
|
||||
multimodal: {
|
||||
enabled: !!data.vlm_config?.enabled
|
||||
|
||||
Reference in New Issue
Block a user