Repository navigation
refactor(go): remove dead atom-split helpers from TokenChunker - #17920
yuzhichang merged 2 commits into
Conversation
Remove splitOversizedUnit, splitAtomByTokenBudget and atomRE from internal/ingestion/component/chunker/token.go, and delete split_oversized_guard_test.go (added by infiniflow#17740). These implemented an atom-split that is never wired into the production merge path (mergeByTokenSize / mergeByTokenSizeFromJSON keep over-budget units whole). They contradict the TokenChunker contract (infiniflow#17799: remove atom-split; over-budget units are kept whole and truncated later by the embedding/rerank layer). Also drop the now-unused wordCount/charCount helpers from token_strict_cap_test.go, and add TestMergeByTokenSize_OversizedUnitStaysWhole to pin the contract invariant on the text path (the JSON path is already covered by TestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe chunker removes oversized-unit atom splitting and related helper tests. A regression test confirms that an oversized delimiter-free unit remains one unchanged chunk. ChangesOversized unit handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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_strict_cap_test.go (1)
142-149: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration history from the test comment.
The comment includes
#17799,split_oversized_guard_test.go, and the reason for deleting the old test. Keep it focused on the current invariant: an oversized delimiter-free text unit remains one unchanged chunk.Proposed comment
-// TestMergeByTokenSize_OversizedUnitStaysWhole mirrors -// TestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole on the text path: a -// single block of text that exceeds chunk_token_size and contains no -// sentence delimiter must be emitted as ONE whole chunk — never atom-split. -// This pins the `#17799` contract invariant on the text path (the JSON path -// is already covered by TestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole). -// It replaces the orphaned split_oversized_guard_test.go, which guarded the -// now-removed atom-split instead of the contract behaviour. +// TestMergeByTokenSize_OversizedUnitStaysWhole verifies that an oversized +// delimiter-free text unit remains one unchanged chunk.As per coding guidelines, keep package comments 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_strict_cap_test.go` around lines 142 - 149, Update the comment above TestMergeByTokenSize_OversizedUnitStaysWhole to remove issue numbers, references to split_oversized_guard_test.go, JSON-path comparison, and migration rationale. Keep only the current invariant that an oversized delimiter-free text unit is emitted as one unchanged chunk without atom-splitting.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_strict_cap_test.go`:
- Around line 142-149: Update the comment above
TestMergeByTokenSize_OversizedUnitStaysWhole to remove issue numbers, references
to split_oversized_guard_test.go, JSON-path comparison, and migration rationale.
Keep only the current invariant that an oversized delimiter-free text unit is
emitted as one unchanged chunk without atom-splitting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97c1f601-6c4a-4504-9329-8a7a88f10677
📒 Files selected for processing (3)
internal/ingestion/component/chunker/split_oversized_guard_test.gointernal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_strict_cap_test.go
💤 Files with no reviewable changes (2)
- internal/ingestion/component/chunker/split_oversized_guard_test.go
- internal/ingestion/component/chunker/token.go
Add a SCOPE bullet to token.go pinning the infiniflow#17799 over-budget-unit contract: keep whole, no atom-split; if oversized-unit handling is ever needed it belongs at the chunker side (or a dedicated PreSplitter stage) with an explicit token budget + tokenizer, NOT in the parser and NOT as a char-window atom-split. This guards against reintroducing the misplaced splitOversizedUnit helpers that were just removed. Trim the migration narrative from TestMergeByTokenSize_OversizedUnitStaysWhole that pointed at the now-removed split_oversized_guard_test.go (per AGENTS.md: drop stale comments describing a superseded design).
|
LGTM |
Summary
splitOversizedUnit,splitAtomByTokenBudgetandatomREfrominternal/ingestion/component/chunker/token.go.split_oversized_guard_test.go(added by test(chunker): self-contained guard for splitOversizedUnit running-sum flush #17740), which guarded the removed atom-split behaviour.wordCount/charCounthelpers fromtoken_strict_cap_test.go.TestMergeByTokenSize_OversizedUnitStaysWholeto pin the Internal discussion: TokenChunker contract — delimiter boundary + token_size soft-target merge #17799 contract invariant (over-budget unit stays whole, never atom-split) on the text path. The JSON path is already covered byTestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole.Why
The production merge path (
mergeByTokenSize/mergeByTokenSizeFromJSON) keeps over-budget units whole and relies on the embedding/rerank layer to truncate them, per the TokenChunker contract (#17799: remove atom-split, no hard_cap). The deleted helpers implemented the opposite behaviour and had no production caller, so they contradicted the contract and misled readers into thinking atom-split was active.Parser vs chunker layering
Python's
_split_oversized_unitlives at the parser layer (pre-split beforenaive_merge), not in the chunker. Go's parser backends are currently skeletons, so there is no parser-side equivalent yet; if added later it belongs ininternal/parser/parser/*, not the chunker.Test plan
bash build.sh --test ./internal/ingestion/component/chunker/...passes; the new text-path test passes and the orphaned atom-split tests are gone.Changes