Skip to content

fix(chunker): drop dead atom-split path in mergeByTokenSizeFromJSON - #17873

Merged
xugangqiang merged 1 commit into
infiniflow:mainfrom
bigfish-emily:fix/chunker-json-overcap-cleanup
Aug 5, 2026
Merged

xugangqiang merged 1 commit into
infiniflow:mainfrom
bigfish-emily:fix/chunker-json-overcap-cleanup

Conversation

@bigfish-emily

Copy link
Copy Markdown
Contributor

Summary

Implements the JSON-path cleanup tracked by #17865 (part 2; the live
text/markdown path stays owned by #17854).

mergeByTokenSizeFromJSON still carried a subSplitOversize parameter whose
true branch atom-split an over-budget unit via splitOversizedUnit. That
branch is unreachable in production (the only true call site short-circuits
before it, and the JSON path always passed false), references the Python
helper _split_oversized_unit that #17808 removed, and contradicts the #17808
OVER_CAP contract: an over-budget unit stands alone as one chunk and the model
layer truncates it later.

This change:

  • removes the subSplitOversize parameter and the atom-split branch, always
    keeping an over-budget unit whole (mirroring Python naive_merge);
  • updates the two mergeByTokenSizeFromJSON call sites in token.go and the
    direct call sites in the token chunker tests;
  • replaces TestMergeByTokenSizeFromJSON_OversizedUnitIsSubSplit with
    TestMergeByTokenSizeFromJSON_OversizedUnitStaysWhole, asserting that an
    over-budget unit is emitted as a single whole chunk.

gofmt clean on all touched files.

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.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

mergeByTokenSizeFromJSON no longer supports oversized-unit sub-splitting. JSON text units over the token budget remain whole chunks. Call sites and tests now use the simplified API and validate the new behavior.

Changes

JSON chunking behavior

Layer / File(s) Summary
Simplify JSON merge behavior
internal/ingestion/component/chunker/token.go
The merge helper no longer accepts subSplitOversize. Oversized JSON text units are emitted as single chunks without splitting or clearing coordinate metadata.
Update merge validation
internal/ingestion/component/chunker/token_*_test.go
Tests use the revised signature. Strict-cap coverage now verifies that oversized units remain unchanged. Existing overlap, boundary, position, and clamping coverage remains updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: xugangqiang, yuzhichang

Poem

A rabbit saw chunks stay whole,
No more splits through every hole.
The token gate now stands clear,
Tests hop after without fear.
mergeByTokenSizeFromJSON sheds one flag,
And carries whole text in its bag.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies removal of the unused atom-splitting path from mergeByTokenSizeFromJSON.
Description check ✅ Passed The description includes the required Summary section and clearly explains the change, rationale, scope, and validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xugangqiang xugangqiang added the ci Continue Integration label Aug 5, 2026
@xugangqiang
xugangqiang marked this pull request as ready for review August 5, 2026 11:11
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Aug 5, 2026
@xugangqiang
xugangqiang requested a review from yuzhichang August 5, 2026 11:12
@xugangqiang xugangqiang added ci Continue Integration and removed ci Continue Integration labels Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)

965-974: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Describe the current Go behavior without migration references.

This doc comment refers to Python behavior and ticket history. Describe mergeByTokenSizeFromJSON as the current Go contract instead. Start the comment with mergeByTokenSizeFromJSON.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1210788 and 07920b7.

📒 Files selected for processing (4)
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_batch1_test.go
  • internal/ingestion/component/chunker/token_pdfpos_test.go
  • internal/ingestion/component/chunker/token_strict_cap_test.go

@xugangqiang
xugangqiang merged commit 2403988 into infiniflow:main Aug 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants