Repository navigation
fix: Go ingestion migration batch 5 (Parser 1.1/1.7/2.11, Chunker 1.7/1.8/2.6/2.7, Tokenizer 6x fixes) - #17419
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe changes preserve chunk metadata, revise token merging, add media enrichment and JSON defaults, introduce TCADP presentation parsing, update tokenizer behavior, and align ingestion integration tests with context-aware APIs. ChangesChunking metadata and token merging
Media dispatch and PDF vision
TCADP presentation parsing
Tokenizer behavior and test API alignment
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ParserComponent
participant PDFVisionEnhancement
participant IMAGE2TEXT
ParserComponent->>PDFVisionEnhancement: dispatch PDF JSON payload
PDFVisionEnhancement->>IMAGE2TEXT: request image or table description
IMAGE2TEXT-->>PDFVisionEnhancement: return description
PDFVisionEnhancement-->>ParserComponent: append description to item text
sequenceDiagram
participant PPTParser
participant PPTXParser
participant TCADP
participant ArtifactConverter
PPTParser->>PPTXParser: configure and delegate parsing
PPTXParser->>TCADP: submit presentation for reconstruction
TCADP-->>PPTXParser: return artifact URL
PPTXParser->>TCADP: download artifact ZIP
PPTXParser->>ArtifactConverter: convert ZIP to structured items
ArtifactConverter-->>PPTXParser: return parse result
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.
Actionable comments posted: 9
🧹 Nitpick comments (3)
internal/ingestion/component/chunker/one_test.go (1)
102-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover both position fields with exact assertions.
The implementation now propagates both
PositionsandPDFPositions, but this test only checks thatpositionsis non-nil. Supplypdf_positionsand assert both output values match the input so an empty or incorrectly transformed payload cannot pass.As per coding guidelines, “Preserve valid behavior with focused tests.”
🤖 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/one_test.go` around lines 102 - 118, Update TestOneChunker_PreservesPositions to include a pdf_positions input alongside positions, then assert both output fields exactly match their respective input values rather than only checking positions is non-nil. Preserve the existing single-chunk validation and use the test’s established chunk output structure.Source: Coding guidelines
internal/ingestion/component/chunker/tag_test.go (1)
149-161: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the actual row indices.
Both checks accept any single-element
top_int, including[0]for both chunks. Assertfloat64(0)andfloat64(1)respectively, as the CSV test already does, to protect the TSV extractor’s row-index contract.As per coding guidelines, “Preserve valid behavior with focused tests.”
🤖 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/tag_test.go` around lines 149 - 161, Update the assertions in the TSV checks around the top_int validation to verify the single element’s value, not only its length: require float64(0) for chunks[0] and float64(1) for chunks[1]. Preserve the existing missing-field and unexpected-type checks while adding focused failures for incorrect row indices.Source: Coding guidelines
internal/parser/parser/ppt_parser_cgo_test.go (1)
71-91: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftTest the actual TCADP request routing.
These tests only inspect fields. Add a local TCADP test server and assert the submitted payload uses
file_type: "PPT"andfile_type: "PPTX"respectively, then return a ZIP artifact to cover the full route.Also applies to: 95-108
🤖 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/parser/parser/ppt_parser_cgo_test.go` around lines 71 - 91, The test currently verifies only parser configuration, not TCADP request routing. Extend the relevant PPT parser tests, including the additional case around the other TCADP test, with a local TCADP server that captures submitted payloads, assert PPT and PPTX requests send the corresponding file_type values, and have the server return a ZIP artifact so the complete request and response path is exercised.
🤖 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.
Inline comments:
In `@internal/ingestion/component/chunker/one.go`:
- Around line 148-149: Remove migration-history annotations and rewrite comments
to describe only current behavior: in
internal/ingestion/component/chunker/one.go lines 148-149 delete diff
annotations, and lines 169-173 retain only the composite-geometry rationale; in
internal/ingestion/component/chunker/tag.go lines 128 and 137-139 remove
annotations and document RowNum’s current contract without Python references; in
internal/ingestion/component/chunker/token.go lines 306-312, 347-362, and
432-453 describe delimiter retention, normalization, single-payload behavior,
and split/merge rationale using only present behavior; update the corresponding
expectations in internal/ingestion/component/chunker/tag_test.go lines 137-139
and 165-169 and internal/ingestion/component/chunker/token_test.go lines
493-497, 531-533, 542-546, 567-571, 593-599, and 626-629 to remove review,
migration, Python, and prior-design wording while retaining concise descriptions
of the tested behavior.
In `@internal/ingestion/component/chunker/tag.go`:
- Line 175: Track the first physical line where the accumulated content becomes
non-empty, and use that contentStartLine when constructing tagPair instead of
the terminating tag row. Update both TSV emission at
internal/ingestion/component/chunker/tag.go:175-175 and CSV emission at
internal/ingestion/component/chunker/tag.go:222-222; preserve the start line
across malformed or multi-line CSV records, and add regression coverage for TSV
and CSV preamble rows.
In `@internal/ingestion/component/media_dispatch_test.go`:
- Around line 320-324: Update the test setup around defaultSetups so it
explicitly clears the audio output format before exercising the fallback path,
rather than relying on the existing default "json" value. Restore the
package-level resolveTenantModelByType resolver after the test completes to
prevent state leaking into other tests.
In `@internal/ingestion/component/parser.go`:
- Around line 494-499: Remove Python-parity and migration-history wording from
the comments at internal/ingestion/component/parser.go:494-499,
internal/ingestion/component/media_dispatch_test.go:314-316, and
internal/ingestion/component/pdf_vision_dispatch.go:554-559. Keep each comment
focused on the current Go behavior: PDF JSON vision enrichment and the expected
default behavior, without Python implementation, diff, or compatibility
references.
In `@internal/ingestion/component/pdf_vision_dispatch.go`:
- Around line 596-604: Update the target-processing loop around the goroutine
launched for each target so the semaphore token is acquired before starting the
goroutine, bounding both goroutine creation and model calls. Remove the
in-goroutine acquisition and ensure each completed worker releases its token
while preserving the existing WaitGroup synchronization and description
handling.
In `@internal/parser/parser/pdf_parser_tcadp_test.go`:
- Around line 119-121: Strengthen the “nested array of elements keeps each page”
test by asserting the parsed item count and validating both nested items’
complete position tuples, including the expected page values for pages 1 and 7.
Apply the same assertion coverage to the related cases around the test’s other
nested-array expectations, rather than checking only items[0].
In `@internal/parser/parser/pdf_parser_tcadp.go`:
- Around line 181-185: Update the default branch in the PDF parser so ordinary
text emitted by emit retains the layout value "text" rather than "layout". Keep
the existing empty-text return behavior unchanged.
- Around line 150-156: Remove migration-history, Python, spreadsheet-comparison,
and compatibility wording from comments across the listed parser and test sites.
Update each comment around the TCADP/PPT/PPTX parser symbols to describe only
current position formatting, delegation, setup forwarding, parse/output
behavior, TCADP operations, and the routing contracts asserted by the tests; all
listed sites require comment-only updates.
In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 20-22: Propagate the caller’s context through the TCADP parsing
flow: update parsePresentationWithTCADP in internal/parser/parser/pptx_tcadp.go
(lines 20-22) to accept context.Context, pass ctx from the caller in
internal/parser/parser/pptx_parser.go (lines 97-103), and use it for
PostJSONRequest (pptx_tcadp.go lines 48-49) and the artifact download request
(lines 70-71) instead of context.Background().
---
Nitpick comments:
In `@internal/ingestion/component/chunker/one_test.go`:
- Around line 102-118: Update TestOneChunker_PreservesPositions to include a
pdf_positions input alongside positions, then assert both output fields exactly
match their respective input values rather than only checking positions is
non-nil. Preserve the existing single-chunk validation and use the test’s
established chunk output structure.
In `@internal/ingestion/component/chunker/tag_test.go`:
- Around line 149-161: Update the assertions in the TSV checks around the
top_int validation to verify the single element’s value, not only its length:
require float64(0) for chunks[0] and float64(1) for chunks[1]. Preserve the
existing missing-field and unexpected-type checks while adding focused failures
for incorrect row indices.
In `@internal/parser/parser/ppt_parser_cgo_test.go`:
- Around line 71-91: The test currently verifies only parser configuration, not
TCADP request routing. Extend the relevant PPT parser tests, including the
additional case around the other TCADP test, with a local TCADP server that
captures submitted payloads, assert PPT and PPTX requests send the corresponding
file_type values, and have the server return a ZIP artifact so the complete
request and response path is exercised.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ede3e03a-d8b1-41e1-88cd-69d89746b7a4
📒 Files selected for processing (16)
internal/ingestion/component/chunker/one.gointernal/ingestion/component/chunker/one_test.gointernal/ingestion/component/chunker/tag.gointernal/ingestion/component/chunker/tag_test.gointernal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_test.gointernal/ingestion/component/media_dispatch.gointernal/ingestion/component/media_dispatch_test.gointernal/ingestion/component/parser.gointernal/ingestion/component/pdf_vision_dispatch.gointernal/parser/parser/pdf_parser_tcadp.gointernal/parser/parser/pdf_parser_tcadp_test.gointernal/parser/parser/ppt_parser.gointernal/parser/parser/ppt_parser_cgo_test.gointernal/parser/parser/pptx_parser.gointernal/parser/parser/pptx_tcadp.go
| Positions: it.Positions, // diff Chunker-1.8 | ||
| PDFPositions: it.PDFPositions, // diff Chunker-1.8 |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Remove migration-history commentary from current Go code and tests.
Keep only concise explanations of the present behavior; remove references to Python parity, old Go behavior, diff batches, and prior review findings.
internal/ingestion/component/chunker/one.go#L148-L149: remove the diff annotations.internal/ingestion/component/chunker/one.go#L169-L173: retain only the current rationale for omitting composite geometry.internal/ingestion/component/chunker/tag.go#L128-L128: remove the diff annotation.internal/ingestion/component/chunker/tag.go#L137-L139: documentRowNum’s current contract without the Python reference.internal/ingestion/component/chunker/token.go#L306-L312: describe delimiter retention without Python-port history.internal/ingestion/component/chunker/token.go#L347-L362: describe normalization and single-payload behavior without prior-design history.internal/ingestion/component/chunker/token.go#L432-L453: retain only the current split/merge rationale.internal/ingestion/component/chunker/tag_test.go#L137-L139: describe the expectedtop_intbehavior without Python references.internal/ingestion/component/chunker/tag_test.go#L165-L169: remove the prior-review reference.internal/ingestion/component/chunker/token_test.go#L493-L497: describe CRLF expectations without migration context.internal/ingestion/component/chunker/token_test.go#L531-L533: remove prior-design commentary.internal/ingestion/component/chunker/token_test.go#L542-L546: describe blank-line expectations without historical implementation details.internal/ingestion/component/chunker/token_test.go#L567-L571: describe delimiter expectations without Python-port history.internal/ingestion/component/chunker/token_test.go#L593-L599: remove review-history and migration wording.internal/ingestion/component/chunker/token_test.go#L626-L629: describe boundary coverage without review-history references.
As per coding guidelines, “Do not add new compatibility wording in comments or documentation.”
📍 Affects 5 files
internal/ingestion/component/chunker/one.go#L148-L149(this comment)internal/ingestion/component/chunker/one.go#L169-L173internal/ingestion/component/chunker/tag.go#L128-L128internal/ingestion/component/chunker/tag.go#L137-L139internal/ingestion/component/chunker/token.go#L306-L312internal/ingestion/component/chunker/token.go#L347-L362internal/ingestion/component/chunker/token.go#L432-L453internal/ingestion/component/chunker/tag_test.go#L137-L139internal/ingestion/component/chunker/tag_test.go#L165-L169internal/ingestion/component/chunker/token_test.go#L493-L497internal/ingestion/component/chunker/token_test.go#L531-L533internal/ingestion/component/chunker/token_test.go#L542-L546internal/ingestion/component/chunker/token_test.go#L567-L571internal/ingestion/component/chunker/token_test.go#L593-L599internal/ingestion/component/chunker/token_test.go#L626-L629
🤖 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/one.go` around lines 148 - 149, Remove
migration-history annotations and rewrite comments to describe only current
behavior: in internal/ingestion/component/chunker/one.go lines 148-149 delete
diff annotations, and lines 169-173 retain only the composite-geometry
rationale; in internal/ingestion/component/chunker/tag.go lines 128 and 137-139
remove annotations and document RowNum’s current contract without Python
references; in internal/ingestion/component/chunker/token.go lines 306-312,
347-362, and 432-453 describe delimiter retention, normalization, single-payload
behavior, and split/merge rationale using only present behavior; update the
corresponding expectations in internal/ingestion/component/chunker/tag_test.go
lines 137-139 and 165-169 and internal/ingestion/component/chunker/token_test.go
lines 493-497, 531-533, 542-546, 567-571, 593-599, and 626-629 to remove review,
migration, Python, and prior-design wording while retaining concise descriptions
of the tested behavior.
Source: Coding guidelines
| // PDF vision figure enhancement: enrich parsed PDF JSON | ||
| // items with vision-model descriptions of embedded | ||
| // images/tables (doc_type_kwd "image"/"table" with non-empty | ||
| // image field). Mirrors Python's enhance_media_sections_with_vision | ||
| // in parser.py:_pdf (diff Parser-1.1). | ||
| dispatched, _, _ = maybeDispatchPDFVisionEnhancement(ctx, fileTypeExt, dispatched, inputs) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove Python-parity and migration-history wording from new Go comments.
Keep comments focused on current Go behavior; the repository guideline prohibits new compatibility wording.
internal/ingestion/component/parser.go#L494-L499: describe PDF JSON vision enrichment without Python or diff references.internal/ingestion/component/media_dispatch_test.go#L314-L316: describe the expected default behavior without Python implementation references.internal/ingestion/component/pdf_vision_dispatch.go#L554-L559: document the enhancement’s Go behavior without Python or diff references.
📍 Affects 3 files
internal/ingestion/component/parser.go#L494-L499(this comment)internal/ingestion/component/media_dispatch_test.go#L314-L316internal/ingestion/component/pdf_vision_dispatch.go#L554-L559
🤖 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/parser.go` around lines 494 - 499, Remove
Python-parity and migration-history wording from the comments at
internal/ingestion/component/parser.go:494-499,
internal/ingestion/component/media_dispatch_test.go:314-316, and
internal/ingestion/component/pdf_vision_dispatch.go:554-559. Keep each comment
focused on the current Go behavior: PDF JSON vision enrichment and the expected
default behavior, without Python implementation, diff, or compatibility
references.
Source: Coding guidelines
| // 0-indexed 5-tuple (page-1). The ingestion pipeline | ||
| // (processChunkPositions -> AddPositions, | ||
| // internal/ingestion/task/position.go) converts this to | ||
| // page_num_int=[page], top_int=[0] and | ||
| // position_int=[[page,0,0,0,0]], mirroring Python | ||
| // presentation.py:148-149. Fixes migration diff Parser-2.13 | ||
| // (presentation TCADP items dropped slide page location). |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove migration-history wording from the new Go comments.
internal/parser/parser/pdf_parser_tcadp.go#L150-L156: describe the current position format only.internal/parser/parser/pdf_parser_tcadp_test.go#L89-L96: describe the tested behavior without migration/Python references.internal/parser/parser/ppt_parser.go#L23-L24: document current delegation behavior only.internal/parser/parser/ppt_parser.go#L37-L39: document current setup forwarding only.internal/parser/parser/ppt_parser.go#L44-L48: document current parse delegation only.internal/parser/parser/ppt_parser_cgo_test.go#L66-L70: state the asserted routing contract only.internal/parser/parser/ppt_parser_cgo_test.go#L93-L94: state the asserted PPTX routing contract only.internal/parser/parser/pptx_parser.go#L37-L37: remove the migration reference.internal/parser/parser/pptx_parser.go#L54-L55: document setup parsing without historical comparison.internal/parser/parser/pptx_parser.go#L83-L85: document current output behavior only.internal/parser/parser/pptx_tcadp.go#L16-L19: document the TCADP operation without spreadsheet/migration comparison.
As per coding guidelines, “Do not add new compatibility wording in comments or documentation,” and Go comments must remain aligned with the current runtime path.
📍 Affects 6 files
internal/parser/parser/pdf_parser_tcadp.go#L150-L156(this comment)internal/parser/parser/pdf_parser_tcadp_test.go#L89-L96internal/parser/parser/ppt_parser.go#L23-L24internal/parser/parser/ppt_parser.go#L37-L39internal/parser/parser/ppt_parser.go#L44-L48internal/parser/parser/ppt_parser_cgo_test.go#L66-L70internal/parser/parser/ppt_parser_cgo_test.go#L93-L94internal/parser/parser/pptx_parser.go#L37-L37internal/parser/parser/pptx_parser.go#L54-L55internal/parser/parser/pptx_parser.go#L83-L85internal/parser/parser/pptx_tcadp.go#L16-L19
🤖 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/parser/parser/pdf_parser_tcadp.go` around lines 150 - 156, Remove
migration-history, Python, spreadsheet-comparison, and compatibility wording
from comments across the listed parser and test sites. Update each comment
around the TCADP/PPT/PPTX parser symbols to describe only current position
formatting, delegation, setup forwarding, parse/output behavior, TCADP
operations, and the routing contracts asserted by the tests; all listed sites
require comment-only updates.
Source: Coding guidelines
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)
293-308: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration-history commentary from Go comments.
Keep these comments focused on the current delimiter and merge semantics; remove Python source paths, prior implementation notes, Chunker/review IDs, and update the adjacent delimiter description so it no longer mentions the removed
.fallback.
internal/ingestion/component/chunker/token.go#L293-L308: document only the active delimiter set and merge behavior.internal/ingestion/component/chunker/token.go#L323-L337: describe LF normalization and whole-payload processing without porting history.internal/ingestion/component/chunker/token.go#L408-L426: describe delimiter-dropping and threshold routing without review references.internal/ingestion/component/chunker/token_test.go#L566-L573: reduce the test comment to its asserted delimiter-removal behavior.internal/ingestion/component/chunker/token_test.go#L595-L607: reduce the test comment to its asserted blank-line behavior.🤖 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 293 - 308, Remove migration-history and review-specific commentary from the documented sites: in internal/ingestion/component/chunker/token.go lines 293-308, 323-337, and 408-426, retain only the active delimiter, merge, LF-normalization, whole-payload, delimiter-dropping, and threshold-routing behavior; in internal/ingestion/component/chunker/token_test.go lines 566-573 and 595-607, reduce comments to the asserted delimiter-removal and blank-line behavior. Update the delimiter description to omit the removed “. ” fallback, and remove Python paths, prior implementation notes, and Chunker/review IDs without changing code behavior.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 293-308: Remove migration-history and review-specific commentary
from the documented sites: in internal/ingestion/component/chunker/token.go
lines 293-308, 323-337, and 408-426, retain only the active delimiter, merge,
LF-normalization, whole-payload, delimiter-dropping, and threshold-routing
behavior; in internal/ingestion/component/chunker/token_test.go lines 566-573
and 595-607, reduce comments to the asserted delimiter-removal and blank-line
behavior. Update the delimiter description to omit the removed “. ” fallback,
and remove Python paths, prior implementation notes, and Chunker/review IDs
without changing code behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 16835a7a-c192-4d71-940b-17e25fe35368
📒 Files selected for processing (7)
internal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_test.gointernal/ingestion/component/pdf_vision_dispatch.gointernal/ingestion/component/tokenizer_test.gointernal/ingestion/service/real_consumer_pipeline_test.gointernal/ingestion/task/real_consumer_test.gointernal/parser/parser/pdf_parser_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (2)
- internal/parser/parser/pdf_parser_tcadp.go
- internal/ingestion/component/pdf_vision_dispatch.go
PR infiniflow#17419 deleted TestTokenChunkerParam_UpdatePreservesOverlappedPercent and the huge-value clamp cases in TestNormalizeOverlappedPercent. The underlying behavior is still correct (Update only writes overlapped_percent when the key is present; clampOverlappedPercent clamps >90 to 90 before the int conversion, avoiding Go's implementation-defined float->int for values like 1e300), so this only restores the regression-safety net those tests provided. - Re-add TestTokenChunkerParam_UpdatePreservesOverlappedPercent - Re-add huge-value clamp cases (1e300 / -1e300 / MaxFloat64)
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@internal/ingestion/component/chunker/token_test.go`:
- Around line 409-412: Revise the comments around the out-of-range normalization
tests in the token test cases to describe only the current contract: clamp huge
values to 90 before converting to an integer, and document the required
partial-update behavior where applicable. Remove Python references,
review-finding numbers, and migration or compatibility history.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2499769d-eae4-4b69-972e-e2b9041038e1
📒 Files selected for processing (1)
internal/ingestion/component/chunker/token_test.go
a8f9472 to
9e3395d
Compare
There was a problem hiding this comment.
Actionable comments posted: 9
🧹 Nitpick comments (2)
internal/ingestion/component/tokenizer.go (1)
120-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration-history references from runtime documentation.
Describe the current invariant directly;
Diff,Omission, Python-path, and migration-parity references will become stale.
internal/ingestion/component/tokenizer.go#L120-L123: document the environment variable, validation, and default only.internal/ingestion/component/tokenizer.go#L357-L359: document the all-path chunk-order invariant only.internal/ingestion/component/tokenizer.go#L510-L513: document the reserved-token behavior only.internal/ingestion/component/tokenizer.go#L578-L581: document the local phantom-filtering rule only.internal/ingestion/component/tokenizer.go#L592-L594: document the local definition of usable chunk content only.internal/ingestion/component/tokenizer_unit_test.go#L353-L354: state the tested phantom-chunk behavior only.internal/ingestion/component/tokenizer_unit_test.go#L373-L375: state the small-token truncation expectation only.internal/ingestion/component/tokenizer_unit_test.go#L390-L392: state the environment configuration behavior only.internal/ingestion/component/tokenizer_unit_test.go#L409-L412: state the embedding-only ordering expectation only.internal/ingestion/component/tokenizer_unit_test.go#L449-L454: state the upstream filtering expectation only.As per coding guidelines, “Keep Go 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/tokenizer.go` around lines 120 - 123, Remove migration-history, Diff/Omission, Python-path, and migration-parity references from the documented comments at internal/ingestion/component/tokenizer.go:120-123, 357-359, 510-513, 578-581, and 592-594, describing only the current environment/default validation, chunk ordering, reserved-token, phantom-filtering, and usable-content invariants respectively. Update internal/ingestion/component/tokenizer_unit_test.go:353-354, 373-375, 390-392, 409-412, and 449-454 likewise to state only each test’s current phantom behavior, truncation expectation, environment configuration, embedding ordering, and upstream filtering behavior.Source: Coding guidelines
internal/ingestion/component/chunker/qa.go (1)
140-141: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFinish or remove the broken migration-comment edits.
internal/ingestion/component/chunker/qa.go#L140-L141: replace the orphaned fragment with a complete metadata-restoration comment.internal/ingestion/component/chunker/token_batch1_test.go#L70-L72: remove the duplicate period.internal/ingestion/component/chunker/token_batch1_test.go#L142-L142: replace the incomplete fragment with a current test description.internal/ingestion/component/chunker/qa_batch2_test.go#L44-L44: describe the tested default behavior without migration wording.internal/ingestion/component/chunker/qa_test.go#L215-L216: remove the duplicate period.internal/ingestion/component/schema/chunker.go#L188-L193: restore the missing separator in theOverlappedPercentsentence.As per coding guidelines, remove “stale documentation” and keep Go documentation 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/qa.go` around lines 140 - 141, Clean up the migration-comment edits across all listed sites: in internal/ingestion/component/chunker/qa.go lines 140-141, replace the orphaned fragment with a complete comment describing metadata restoration; in internal/ingestion/component/chunker/token_batch1_test.go lines 70-72 remove the duplicate period and line 142 replace the incomplete fragment with the current test description; in internal/ingestion/component/chunker/qa_batch2_test.go line 44 describe the tested default behavior without migration wording; in internal/ingestion/component/chunker/qa_test.go lines 215-216 remove the duplicate period; and in internal/ingestion/component/schema/chunker.go lines 188-193 restore the missing separator in the OverlappedPercent documentation sentence.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.
Inline comments:
In `@internal/ingestion/component/chunker/tag_test.go`:
- Around line 149-162: Update the top_int assertions in the chunk verification
to validate the contained row index, not only that each value is a one-element
[]any. Ensure chunk 0 contains 0 and chunk 1 contains 1, while retaining the
existing missing-key and unexpected-type checks.
In `@internal/ingestion/component/chunker/title.go`:
- Around line 767-769: Update the dispatch cases in the component’s invoke flow
to pass the resolved name value into both invokeHierarchy and invokeGroup
instead of the original c.param map, preserving the upstream re-decode/cropping
behavior for globals-only runs.
In `@internal/ingestion/component/chunker/token.go`:
- Around line 382-385: Update the comment immediately above sentenceDelimiter to
accurately describe only the delimiters supported by the regex, removing the
claim that English ". " is included while retaining the documented Python
delimiters and ASCII punctuation details.
In `@internal/ingestion/component/media_dispatch.go`:
- Around line 376-379: Remove the unused videoMIME helper and its associated
future-video-parsing reference comment from the media dispatch implementation,
leaving maybeDispatchVideo and the existing unsupported-video behavior
unchanged.
- Around line 65-79: Update the video-parsing comment in maybeDispatchVideo to
describe only current behavior, removing references to the previously shipped
path, migration history, and docs/migration_python_go_diff.md. Preserve the
current provider-specific implementation guidance and explicit unsupported
error. In defaultSetups, simplify the "video" entry by removing unused
output_format and prompt values, retaining only the suffix list.
In `@internal/ingestion/component/tokenizer_unit_test.go`:
- Line 26: Update TestEmbeddingBatchSizeEnvVar to capture the existing
TOKENIZER_EMBEDDING_BATCH_SIZE value before exercising each case, then restore
that value during cleanup instead of unconditionally removing it. Ensure the
test’s default assertion is isolated from the caller’s process environment and
cleanup runs only after all cases complete.
In `@internal/ingestion/component/tokenizer.go`:
- Line 716: Update the Summary branch in the chunk tokenization logic to trim
ck.Summary before checking whether it is empty, so whitespace-only summaries
fall back to ck.Text. Preserve the existing behavior for summaries containing
non-whitespace content.
- Around line 592-596: The isPhantomChunk predicate currently discards
summary-only chunks and retains whitespace-only content. Update isPhantomChunk
to trim every indexable content field, including Text, Image, ContentWithWeight,
Summary, Questions, and Keywords, and return true only when all trimmed values
are empty; preserve chunks containing any meaningful content.
In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 78-86: Update the download flow in the TCADP parser around
NewDriverHTTPClient().Do so it validates downloadResp.StatusCode before reading
or parsing the ZIP, returning a ParseResult error for non-2xx responses.
Preserve the existing response-body cleanup and successful ZIP-reading path for
2xx responses.
---
Nitpick comments:
In `@internal/ingestion/component/chunker/qa.go`:
- Around line 140-141: Clean up the migration-comment edits across all listed
sites: in internal/ingestion/component/chunker/qa.go lines 140-141, replace the
orphaned fragment with a complete comment describing metadata restoration; in
internal/ingestion/component/chunker/token_batch1_test.go lines 70-72 remove the
duplicate period and line 142 replace the incomplete fragment with the current
test description; in internal/ingestion/component/chunker/qa_batch2_test.go line
44 describe the tested default behavior without migration wording; in
internal/ingestion/component/chunker/qa_test.go lines 215-216 remove the
duplicate period; and in internal/ingestion/component/schema/chunker.go lines
188-193 restore the missing separator in the OverlappedPercent documentation
sentence.
In `@internal/ingestion/component/tokenizer.go`:
- Around line 120-123: Remove migration-history, Diff/Omission, Python-path, and
migration-parity references from the documented comments at
internal/ingestion/component/tokenizer.go:120-123, 357-359, 510-513, 578-581,
and 592-594, describing only the current environment/default validation, chunk
ordering, reserved-token, phantom-filtering, and usable-content invariants
respectively. Update
internal/ingestion/component/tokenizer_unit_test.go:353-354, 373-375, 390-392,
409-412, and 449-454 likewise to state only each test’s current phantom
behavior, truncation expectation, environment configuration, embedding ordering,
and upstream filtering behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f2e7b0f7-dcf6-4c25-9cda-303a98546279
📒 Files selected for processing (32)
internal/ingestion/component/chunker/crop_title_test.gointernal/ingestion/component/chunker/group.gointernal/ingestion/component/chunker/hierarchy.gointernal/ingestion/component/chunker/one.gointernal/ingestion/component/chunker/one_test.gointernal/ingestion/component/chunker/qa.gointernal/ingestion/component/chunker/qa_batch2_test.gointernal/ingestion/component/chunker/qa_test.gointernal/ingestion/component/chunker/tag.gointernal/ingestion/component/chunker/tag_test.gointernal/ingestion/component/chunker/title.gointernal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_batch1_test.gointernal/ingestion/component/chunker/token_tag_test.gointernal/ingestion/component/chunker/token_test.gointernal/ingestion/component/media_dispatch.gointernal/ingestion/component/media_dispatch_test.gointernal/ingestion/component/parser.gointernal/ingestion/component/pdf_vision_dispatch.gointernal/ingestion/component/schema/chunker.gointernal/ingestion/component/tokenizer.gointernal/ingestion/component/tokenizer_test.gointernal/ingestion/component/tokenizer_unit_test.gointernal/ingestion/pipeline/template_integration_test.gointernal/ingestion/service/real_consumer_pipeline_test.gointernal/ingestion/task/real_consumer_test.gointernal/parser/parser/pdf_parser_tcadp.gointernal/parser/parser/pdf_parser_tcadp_test.gointernal/parser/parser/ppt_parser.gointernal/parser/parser/ppt_parser_cgo_test.gointernal/parser/parser/pptx_parser.gointernal/parser/parser/pptx_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (12)
- internal/ingestion/component/chunker/one_test.go
- internal/ingestion/component/media_dispatch_test.go
- internal/ingestion/component/chunker/one.go
- internal/parser/parser/ppt_parser_cgo_test.go
- internal/parser/parser/ppt_parser.go
- internal/ingestion/task/real_consumer_test.go
- internal/parser/parser/pdf_parser_tcadp_test.go
- internal/parser/parser/pdf_parser_tcadp.go
- internal/parser/parser/pptx_parser.go
- internal/ingestion/component/chunker/tag.go
- internal/ingestion/component/pdf_vision_dispatch.go
- internal/ingestion/component/chunker/token_test.go
| return invokeHierarchy(ctx, db, inputs, &c.param) | ||
| case "group": | ||
| return invokeGroup(ctx, inputs, &c.param) | ||
| return invokeGroup(ctx, db, inputs, &c.param) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Forward the resolved name into the dispatch helpers.
Unlike the direct Group/Hierarchy components, these paths pass the original map. Globals-only runs can therefore miss the newly added upstream re-decode/cropping path.
Proposed fix
case "hierarchy":
- return invokeHierarchy(ctx, db, inputs, &c.param)
+ return invokeHierarchy(ctx, db, withName(inputs, name), &c.param)
case "group":
- return invokeGroup(ctx, db, inputs, &c.param)
+ return invokeGroup(ctx, db, withName(inputs, name), &c.param)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return invokeHierarchy(ctx, db, inputs, &c.param) | |
| case "group": | |
| return invokeGroup(ctx, inputs, &c.param) | |
| return invokeGroup(ctx, db, inputs, &c.param) | |
| return invokeHierarchy(ctx, db, withName(inputs, name), &c.param) | |
| case "group": | |
| return invokeGroup(ctx, db, withName(inputs, name), &c.param) |
🤖 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/title.go` around lines 767 - 769, Update
the dispatch cases in the component’s invoke flow to pass the resolved name
value into both invokeHierarchy and invokeGroup instead of the original c.param
map, preserving the upstream re-decode/cropping behavior for globals-only runs.
| if _, ok := setups["video"]; !ok { | ||
| return parserDispatchResult{}, false, nil | ||
| } | ||
| tenantID := getStringOr(inputs, "tenant_id", "") | ||
| if tenantID == "" { | ||
| return parserDispatchResult{}, true, | ||
| fmt.Errorf("Parser: video requires tenant_id") | ||
| } | ||
|
|
||
| // Resolve the tenant's IMAGE2TEXT model. | ||
| driver, modelName, apiConfig, _, err := resolveTenantModelByType(tenantID, entity.ModelTypeImage2Text) | ||
| if err != nil { | ||
| return parserDispatchResult{}, true, | ||
| fmt.Errorf("Parser: video image2text model: %w", err) | ||
| } | ||
|
|
||
| videoPrompt, _ := setup["prompt"].(string) | ||
| videoB64 := base64.StdEncoding.EncodeToString(binary) | ||
|
|
||
| // Build a multimodal message with the video payload. | ||
| // Python uses cv_mdl.async_chat(video_bytes=blob, ...); | ||
| // Go ChatWithMessages is synchronous and uses a data URI. | ||
| mimeType := videoMIME(filename) | ||
| dataURI := "data:" + mimeType + ";base64," + videoB64 | ||
| messages := []modelModule.Message{{ | ||
| Role: "user", | ||
| Content: []interface{}{ | ||
| map[string]any{"type": "text", "text": videoPrompt}, | ||
| map[string]any{"type": "video_url", "video_url": map[string]any{"url": dataURI}}, | ||
| }, | ||
| }} | ||
| vision := true | ||
| resp, err := driver.ChatWithMessages(ctx, modelName, messages, apiConfig, &modelModule.ChatConfig{Vision: &vision}, nil) | ||
| if err != nil { | ||
| return parserDispatchResult{}, true, | ||
| fmt.Errorf("Parser: video describe: %w", err) | ||
| } | ||
| txt := "" | ||
| if resp != nil && resp.Answer != nil { | ||
| txt = strings.TrimSpace(*resp.Answer) | ||
| } | ||
|
|
||
| outputFormat, _ := setup["output_format"].(string) | ||
| if outputFormat == "" { | ||
| outputFormat = "text" | ||
| } | ||
| return parserDispatchResult{ | ||
| OutputFormat: outputFormat, | ||
| DocType: "video", | ||
| Text: txt, | ||
| }, true, nil | ||
| // Video parsing is intentionally not implemented yet: the underlying | ||
| // video-analysis capability is pending. The previously-shipped path sent a | ||
| // video_url data URI, but no model driver honors it — OpenAI-compatible | ||
| // drivers only accept image_url (the block is ignored), and Gemini's | ||
| // googleMessageParts only accepts text/image_url and silently drops | ||
| // video_url. Returning an explicit error is safer than silently producing | ||
| // a description from the prompt text alone. The real implementation must | ||
| // be provider-specific (OpenAI-compatible: frame extraction -> image_url; | ||
| // Gemini: raw-bytes inline_data; Qwen: file://) — see | ||
| // docs/migration_python_go_diff.md 2.7. | ||
| return parserDispatchResult{}, true, | ||
| fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending") |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Drop migration-history wording from the new comment.
The rationale for deferring video parsing is useful, but referencing docs/migration_python_go_diff.md 2.7 and "the previously-shipped path" ties this Go doc comment to migration history rather than describing current behavior.
Separately, since maybeDispatchVideo no longer reads output_format/prompt from the video setup (it only checks key presence), the "video" entry in defaultSetups() (internal/ingestion/component/parser.go lines 316-320: output_format: "text", prompt: "") is now dead configuration — worth pruning to just the suffix list.
♻️ Proposed comment cleanup
- // Video parsing is intentionally not implemented yet: the underlying
- // video-analysis capability is pending. The previously-shipped path sent a
- // video_url data URI, but no model driver honors it — OpenAI-compatible
- // drivers only accept image_url (the block is ignored), and Gemini's
- // googleMessageParts only accepts text/image_url and silently drops
- // video_url. Returning an explicit error is safer than silently producing
- // a description from the prompt text alone. The real implementation must
- // be provider-specific (OpenAI-compatible: frame extraction -> image_url;
- // Gemini: raw-bytes inline_data; Qwen: file://) — see
- // docs/migration_python_go_diff.md 2.7.
+ // Video parsing is intentionally not implemented yet: no model driver
+ // accepts a video_url payload today (OpenAI-compatible drivers ignore
+ // it; Gemini's message builder silently drops it). Returning an
+ // explicit error is safer than silently producing a description from
+ // prompt text alone. A real implementation must be provider-specific
+ // (OpenAI-compatible: frame extraction -> image_url; Gemini: raw-bytes
+ // inline_data; Qwen: file://).As per coding guidelines, "Keep Go package comments and doc comments aligned with the current runtime path rather than migration history."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if _, ok := setups["video"]; !ok { | |
| return parserDispatchResult{}, false, nil | |
| } | |
| tenantID := getStringOr(inputs, "tenant_id", "") | |
| if tenantID == "" { | |
| return parserDispatchResult{}, true, | |
| fmt.Errorf("Parser: video requires tenant_id") | |
| } | |
| // Resolve the tenant's IMAGE2TEXT model. | |
| driver, modelName, apiConfig, _, err := resolveTenantModelByType(tenantID, entity.ModelTypeImage2Text) | |
| if err != nil { | |
| return parserDispatchResult{}, true, | |
| fmt.Errorf("Parser: video image2text model: %w", err) | |
| } | |
| videoPrompt, _ := setup["prompt"].(string) | |
| videoB64 := base64.StdEncoding.EncodeToString(binary) | |
| // Build a multimodal message with the video payload. | |
| // Python uses cv_mdl.async_chat(video_bytes=blob, ...); | |
| // Go ChatWithMessages is synchronous and uses a data URI. | |
| mimeType := videoMIME(filename) | |
| dataURI := "data:" + mimeType + ";base64," + videoB64 | |
| messages := []modelModule.Message{{ | |
| Role: "user", | |
| Content: []interface{}{ | |
| map[string]any{"type": "text", "text": videoPrompt}, | |
| map[string]any{"type": "video_url", "video_url": map[string]any{"url": dataURI}}, | |
| }, | |
| }} | |
| vision := true | |
| resp, err := driver.ChatWithMessages(ctx, modelName, messages, apiConfig, &modelModule.ChatConfig{Vision: &vision}, nil) | |
| if err != nil { | |
| return parserDispatchResult{}, true, | |
| fmt.Errorf("Parser: video describe: %w", err) | |
| } | |
| txt := "" | |
| if resp != nil && resp.Answer != nil { | |
| txt = strings.TrimSpace(*resp.Answer) | |
| } | |
| outputFormat, _ := setup["output_format"].(string) | |
| if outputFormat == "" { | |
| outputFormat = "text" | |
| } | |
| return parserDispatchResult{ | |
| OutputFormat: outputFormat, | |
| DocType: "video", | |
| Text: txt, | |
| }, true, nil | |
| // Video parsing is intentionally not implemented yet: the underlying | |
| // video-analysis capability is pending. The previously-shipped path sent a | |
| // video_url data URI, but no model driver honors it — OpenAI-compatible | |
| // drivers only accept image_url (the block is ignored), and Gemini's | |
| // googleMessageParts only accepts text/image_url and silently drops | |
| // video_url. Returning an explicit error is safer than silently producing | |
| // a description from the prompt text alone. The real implementation must | |
| // be provider-specific (OpenAI-compatible: frame extraction -> image_url; | |
| // Gemini: raw-bytes inline_data; Qwen: file://) — see | |
| // docs/migration_python_go_diff.md 2.7. | |
| return parserDispatchResult{}, true, | |
| fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending") | |
| if _, ok := setups["video"]; !ok { | |
| return parserDispatchResult{}, false, nil | |
| } | |
| // Video parsing is intentionally not implemented yet: no model driver | |
| // accepts a video_url payload today (OpenAI-compatible drivers ignore | |
| // it; Gemini's message builder silently drops it). Returning an | |
| // explicit error is safer than silently producing a description from | |
| // prompt text alone. A real implementation must be provider-specific | |
| // (OpenAI-compatible: frame extraction -> image_url; Gemini: raw-bytes | |
| // inline_data; Qwen: file://). | |
| return parserDispatchResult{}, true, | |
| fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending") |
🤖 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/media_dispatch.go` around lines 65 - 79, Update
the video-parsing comment in maybeDispatchVideo to describe only current
behavior, removing references to the previously shipped path, migration history,
and docs/migration_python_go_diff.md. Preserve the current provider-specific
implementation guidance and explicit unsupported error. In defaultSetups,
simplify the "video" entry by removing unused output_format and prompt values,
retaining only the suffix list.
Source: Coding guidelines
| // for constructing base64 data URIs. Retained as a reference for the | ||
| // future real video-parsing implementation (provider-specific frame | ||
| // extraction / inline_data / file://); not currently used because | ||
| // maybeDispatchVideo returns an explicit unsupported error. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm videoMIME has no remaining callers before deleting.
rg -n 'videoMIME' --type=goRepository: infiniflow/ragflow
Length of output: 156
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files named media_dispatch.go:"
fd -a 'media_dispatch\.go$' . || true
echo
echo "Occurrences of videoMIME in tracked files:"
git grep -n 'videoMIME' || true
echo
echo "Occurrences of maybeDispatchVideo in tracked Go files:"
git grep -n 'maybeDispatchVideo' -- '*.go' || true
echo
echo "Relevant lines in internal/ingestion/component/media_dispatch.go:"
sed -n '350,395p' internal/ingestion/component/media_dispatch.goRepository: infiniflow/ragflow
Length of output: 2260
Remove the unused videoMIME helper.
videoMIME has no Callers, and this is explicitly a placeholder reference to future video parsing. Delete the function and its comment to avoid retaining dead migration/dual-track code.
🤖 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/media_dispatch.go` around lines 376 - 379,
Remove the unused videoMIME helper and its associated future-video-parsing
reference comment from the media dispatch implementation, leaving
maybeDispatchVideo and the existing unsupported-video behavior unchanged.
Source: Coding guidelines
| // isPhantomChunk returns true when a ChunkDoc has no usable content | ||
| // for downstream tokenization or embedding. Mirrors Python's | ||
| // none-chunk filtering (diff Tokenizer Omission-2). | ||
| func isPhantomChunk(ck schema.ChunkDoc) bool { | ||
| return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == "" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve meaningful chunks and remove whitespace-only ones.
This runs before tokenizeChunks, which supports Summary, Questions, and Keywords; summary-only chunks are currently discarded. Conversely, whitespace-only Text/Image/ContentWithWeight values survive as phantom chunks. Base this predicate on trimmed values of all indexable content fields.
Proposed fix
func isPhantomChunk(ck schema.ChunkDoc) bool {
- return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == ""
+ return strings.TrimSpace(ck.Text) == "" &&
+ strings.TrimSpace(ck.Image) == "" &&
+ strings.TrimSpace(ck.ContentWithWeight) == "" &&
+ strings.TrimSpace(ck.Summary) == "" &&
+ strings.TrimSpace(ck.Questions) == "" &&
+ strings.TrimSpace(ck.Keywords) == ""
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // isPhantomChunk returns true when a ChunkDoc has no usable content | |
| // for downstream tokenization or embedding. Mirrors Python's | |
| // none-chunk filtering (diff Tokenizer Omission-2). | |
| func isPhantomChunk(ck schema.ChunkDoc) bool { | |
| return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == "" | |
| // isPhantomChunk returns true when a ChunkDoc has no usable content | |
| // for downstream tokenization or embedding. Mirrors Python's | |
| // none-chunk filtering (diff Tokenizer Omission-2). | |
| func isPhantomChunk(ck schema.ChunkDoc) bool { | |
| return strings.TrimSpace(ck.Text) == "" && | |
| strings.TrimSpace(ck.Image) == "" && | |
| strings.TrimSpace(ck.ContentWithWeight) == "" && | |
| strings.TrimSpace(ck.Summary) == "" && | |
| strings.TrimSpace(ck.Questions) == "" && | |
| strings.TrimSpace(ck.Keywords) == "" | |
| } |
🤖 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/tokenizer.go` around lines 592 - 596, The
isPhantomChunk predicate currently discards summary-only chunks and retains
whitespace-only content. Update isPhantomChunk to trim every indexable content
field, including Text, Image, ContentWithWeight, Summary, Questions, and
Keywords, and return true only when all trimmed values are empty; preserve
chunks containing any meaningful content.
9e3395d to
5e19315
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
internal/ingestion/component/chunker/token_tag_test.go (1)
22-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration-history terminology from test comments.
“Residual B” is not meaningful runtime behavior and will become stale; describe only the parser-tag cleanup contract.
Proposed cleanup
-// TestTokenChunker_TextPath_StripsParserTags pins residual B: the -// TokenChunker text path must not leak parser position tags (@@...##) +// TestTokenChunker_TextPath_StripsParserTags verifies that the +// TokenChunker text path does not leak parser position tags (@@...##) ... -// TestTokenChunker_JSONPath_StripsParserTags pins residual B for the -// structured (output_format == "json") path. +// TestTokenChunker_JSONPath_StripsParserTags verifies the same behavior +// for the structured (output_format == "json") path.As per coding guidelines, “Remove dead tests, commented-out code, stale documentation, and 'move later' notes instead of preserving them.”
Also applies to: 55-56
🤖 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_tag_test.go` around lines 22 - 25, Update the comments for TestTokenChunker_TextPath_StripsParserTags, including the additional referenced comment range, to remove migration-history terminology such as “Residual B.” Keep only the runtime contract that parser position tags must not appear in final chunk text.Source: Coding guidelines
internal/ingestion/component/chunker/crop_title_test.go (1)
24-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration-era and line-number references from the test contract.
residual A, the TokenChunker comparison, andpdfcrop_cgo.go:151describe migration/history rather than the observable behavior under test. Keep the comment focused on inputs and expected output. As per coding guidelines, remove stale documentation and keep Go 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/crop_title_test.go` around lines 24 - 32, Update the comment above TestCropTitleChunks_CropsPositionedChunk to remove migration/history references, including “residual A,” the TokenChunker comparison, and the pdfcrop_cgo.go line reference. Keep only the observable contract: chunk inputs may contain doc_type_kwd and positions without ck_type, positioned text chunks receive a rendered preview, positionless chunks remain unchanged, and derived ck_type is absent from the returned shape.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.
Inline comments:
In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 1-14: Restore parser test-package compilation by removing the
unused context imports from office_parsers_nocgo_test.go and
pdf_parser_nocgo_test.go, unless those tests are updated to use context. Leave
the production imports in pptx_tcadp.go unchanged.
---
Nitpick comments:
In `@internal/ingestion/component/chunker/crop_title_test.go`:
- Around line 24-32: Update the comment above
TestCropTitleChunks_CropsPositionedChunk to remove migration/history references,
including “residual A,” the TokenChunker comparison, and the pdfcrop_cgo.go line
reference. Keep only the observable contract: chunk inputs may contain
doc_type_kwd and positions without ck_type, positioned text chunks receive a
rendered preview, positionless chunks remain unchanged, and derived ck_type is
absent from the returned shape.
In `@internal/ingestion/component/chunker/token_tag_test.go`:
- Around line 22-25: Update the comments for
TestTokenChunker_TextPath_StripsParserTags, including the additional referenced
comment range, to remove migration-history terminology such as “Residual B.”
Keep only the runtime contract that parser position tags must not appear in
final chunk text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e96d1972-7d2a-40dd-a25f-b92f3588b44b
📒 Files selected for processing (32)
internal/ingestion/component/chunker/crop_title_test.gointernal/ingestion/component/chunker/group.gointernal/ingestion/component/chunker/hierarchy.gointernal/ingestion/component/chunker/one.gointernal/ingestion/component/chunker/one_test.gointernal/ingestion/component/chunker/qa.gointernal/ingestion/component/chunker/qa_batch2_test.gointernal/ingestion/component/chunker/qa_test.gointernal/ingestion/component/chunker/tag.gointernal/ingestion/component/chunker/tag_test.gointernal/ingestion/component/chunker/title.gointernal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_batch1_test.gointernal/ingestion/component/chunker/token_tag_test.gointernal/ingestion/component/chunker/token_test.gointernal/ingestion/component/media_dispatch.gointernal/ingestion/component/media_dispatch_test.gointernal/ingestion/component/parser.gointernal/ingestion/component/pdf_vision_dispatch.gointernal/ingestion/component/schema/chunker.gointernal/ingestion/component/tokenizer.gointernal/ingestion/component/tokenizer_test.gointernal/ingestion/component/tokenizer_unit_test.gointernal/ingestion/pipeline/template_integration_test.gointernal/ingestion/service/real_consumer_pipeline_test.gointernal/ingestion/task/real_consumer_test.gointernal/parser/parser/pdf_parser_tcadp.gointernal/parser/parser/pdf_parser_tcadp_test.gointernal/parser/parser/ppt_parser.gointernal/parser/parser/ppt_parser_cgo_test.gointernal/parser/parser/pptx_parser.gointernal/parser/parser/pptx_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (29)
- internal/ingestion/component/chunker/one_test.go
- internal/ingestion/component/chunker/qa_test.go
- internal/ingestion/component/chunker/qa_batch2_test.go
- internal/ingestion/component/schema/chunker.go
- internal/parser/parser/pdf_parser_tcadp.go
- internal/ingestion/service/real_consumer_pipeline_test.go
- internal/parser/parser/ppt_parser_cgo_test.go
- internal/ingestion/component/chunker/qa.go
- internal/ingestion/component/chunker/token_batch1_test.go
- internal/ingestion/pipeline/template_integration_test.go
- internal/ingestion/task/real_consumer_test.go
- internal/ingestion/component/chunker/one.go
- internal/ingestion/component/media_dispatch.go
- internal/ingestion/component/chunker/hierarchy.go
- internal/parser/parser/ppt_parser.go
- internal/ingestion/component/tokenizer_unit_test.go
- internal/ingestion/component/chunker/tag_test.go
- internal/parser/parser/pptx_parser.go
- internal/ingestion/component/parser.go
- internal/ingestion/component/chunker/title.go
- internal/ingestion/component/chunker/group.go
- internal/ingestion/component/media_dispatch_test.go
- internal/ingestion/component/chunker/tag.go
- internal/parser/parser/pdf_parser_tcadp_test.go
- internal/ingestion/component/chunker/token.go
- internal/ingestion/component/tokenizer_test.go
- internal/ingestion/component/tokenizer.go
- internal/ingestion/component/pdf_vision_dispatch.go
- internal/ingestion/component/chunker/token_test.go
10cecb4 to
4e18a75
Compare
|
@yingfeng @yuzhichang @JinHai-CN pls help to review |
| // (10 min) to match the canvas-level component timeout default. | ||
| // Invalid / non-positive values fall back to the default. | ||
| // Reads COMPONENT_EXEC_TIMEOUT_TOKENIZER env var (seconds); defaults to 60s | ||
| // to match Python's @timeout(60). Invalid / non-positive values fall back |
There was a problem hiding this comment.
I think Python's component timeout is a bad design.
|
LGTM |
Summary
Continuation of the Python→Go ingestion pipeline migration (File → Parser → Chunker → Extractor → Tokenizer). Fixes cover Parser, Chunker, and Tokenizer gaps identified. Fix page number (0-indexed and 1-index mixed before fix; use 1-indexed after fix) and chunk order issues.
Parser
pptx_tcadp.go+ TCADP branch inpptx_parser.go/ppt_parser.go— PowerPoint files now supportparse_method="tcadp"via the TCADP cloud service, matching the spreadsheet-family TCADP pattern. PPT containers pass"PPT"as fileType (not hardcoded"PPTX").defaultSetups()audio default changed from"text"to"json", aligning with Pythonparser.py:232andAllowedOutputFormat["audio"]={"json"}.maybeDispatchPDFVisionEnhancementinpdf_vision_dispatch.goenriches image/table items with IMAGE2TEXT model descriptions after PDF parsing, mirroring Pythonenhance_media_sections_with_vision. Semaphore fix: acquire before goroutine start to prevent unbounded goroutine creation.json_parser.gois a functional enhancement, not a parity gap.Chunker
resolveTitleLevels(title.go) detects bullet/numbered-list patterns (Chinese legal, numbering, English) when outline + regex levels produce only bodyLevel. Guarded byallBodyLevelto never override existing structure.tag.gosetsTopIntfrom source row index;one.gopreservesPositions/PDFPositionsfrom source items. TSV multi-line RowNum fix: trackscontentStartfor correct row attribution.NormalizeOverlappedPercentinschema/chunker.gomirrors Pythoncommon/float_utils.py:50-58— accepts[0,1)fraction or[0,90]percent, normalizes to canonical[0,90].naive_merge—CRLFnormalization,splitKeepingDelimiterpreserves sentence delimiters, single-section merge with token-budget-governed chunking.Tokenizer
isPhantomChunk+ filter loop inchunksFromTokenizerUpstreamskips zero-value ChunkDocs.embeddingBatchSize()readsTOKENIZER_EMBEDDING_BATCH_SIZE, defaults to 16.TrimSpace(s) != ""→s != "", matching Python truthy check.600s→60s, matching Python@timeout(60).truncateForEmbeddingreturns""whenmaxTokens <= 10, matching Python.Code review fixes
pdf_vision_dispatch.go(concurrency control)pptx_tcadp.go(cancellation support)media_dispatch_test.go(defer restore)Test plan
Notes
docs/migration_python_go_diff.md