Repository navigation
fix(chunker): drop dead atom-split path in mergeByTokenSizeFromJSON - #17873
Conversation
Per infiniflow#17865: the subSplitOversize=true branch is unreachable in production, references the removed Python helper, and contradicts the infiniflow#17808 OVER_CAP contract. Over-budget units now always stand alone as one chunk. Replaces the sub-split unit test with an over-budget-stays-whole test.
📝 WalkthroughWalkthrough
ChangesJSON chunking behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)
965-974: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDescribe the current Go behavior without migration references.
This doc comment refers to Python behavior and ticket history. Describe
mergeByTokenSizeFromJSONas the current Go contract instead. Start the comment withmergeByTokenSizeFromJSON.Proposed update
-// Over-budget units are never atom-split: each one stands alone as its own -// chunk (Python naive_merge behavior, `#17808` OVER_CAP contract). Overlap is +// mergeByTokenSizeFromJSON merges text chunks within each item. +// Over-budget units remain whole and stand alone as their own chunks. Overlap is // applied only when overlap+segment still fits the budget.As per coding guidelines,
**/*.go: “Remove commented-out Go code and keep package and doc comments aligned with the current runtime path rather than migration history.”🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/ingestion/component/chunker/token.go` around lines 965 - 974, Rewrite the doc comment immediately above mergeByTokenSizeFromJSON to start with that function name and describe only its current Go contract. Remove Python behavior references, ticket/history references, and migration context while retaining the documented MergeOverCap and MergeUnderCap semantics, standalone handling of over-budget units, and overlap budget rule.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/ingestion/component/chunker/token.go`:
- Around line 965-974: Rewrite the doc comment immediately above
mergeByTokenSizeFromJSON to start with that function name and describe only its
current Go contract. Remove Python behavior references, ticket/history
references, and migration context while retaining the documented MergeOverCap
and MergeUnderCap semantics, standalone handling of over-budget units, and
overlap budget rule.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b7b6ec7c-a498-463e-aae3-e471872fc214
📒 Files selected for processing (4)
internal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_batch1_test.gointernal/ingestion/component/chunker/token_pdfpos_test.gointernal/ingestion/component/chunker/token_strict_cap_test.go
Summary
Implements the JSON-path cleanup tracked by #17865 (part 2; the live
text/markdown path stays owned by #17854).
mergeByTokenSizeFromJSONstill carried asubSplitOversizeparameter whosetruebranch atom-split an over-budget unit viasplitOversizedUnit. Thatbranch is unreachable in production (the only
truecall site short-circuitsbefore it, and the JSON path always passed
false), references the Pythonhelper
_split_oversized_unitthat #17808 removed, and contradicts the #17808OVER_CAP contract: an over-budget unit stands alone as one chunk and the model
layer truncates it later.
This change:
subSplitOversizeparameter and the atom-split branch, alwayskeeping an over-budget unit whole (mirroring Python
naive_merge);mergeByTokenSizeFromJSONcall sites intoken.goand thedirect call sites in the token chunker tests;
TestMergeByTokenSizeFromJSON_OversizedUnitIsSubSplitwithTestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole, asserting that anover-budget unit is emitted as a single whole chunk.
gofmtclean on all touched files.