Fix/149 structural chunker silently drops documents - #1014
Open
JohnPhm wants to merge 10 commits into
Open
Conversation
… planning (PLAN.md)
…unker.py, edited JOURNAL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request proposes changes to the functionality of the structural chunker. It fixes the issue where the structural chunker simply drops documents silently if certain conditions are not met. By fixing this issue, it prevents data loss during ingestion (notably for README documents, the main path routed through this chunker), keeping the search index complete.
Issue
Closes #149 structural chunker silently drops documents
Changes
Root Cause: flawed assumption in _extract_sections(): the code assumes every document is organized by headings, so it only keeps content once a heading exists. When no heading exists, content is never collected and no section is ever saved so the whole document silently disappears. This means that a heading-less document produced zero chunks and was excluded from the RAG index with no error or warning.
+added JOURNAL.md, detailing what was built/added and it also discusses what tests were used to confirm that the fix is working, the actual fix itself, and includes information on how to find this PR itself and the branch that contains all of the changes and commits
+edited structural_chunker.py, detailing the fix with the content guard
+edited test_structural_chunker.py, adding an assert statement to both test_heading_path_format and test_heading_path_breadcrumb functions to prevent the tests from passing if the chunk() returned nothing.
##Reproduction
Testing
make test-unit), running 'make test-unit' introduces no new failures. Furthermore, using the command 'python -m pytest tests/unit/test_structural_chunker.py::TestStructuralChunker::test_document_with_no_headings -v' allows us to use the testing function for the heading-less document and it passes with the fix when it failed before. We could also use the entire testing file (test_structural_chunker.py) with the command 'python -m pytest tests/unit/test_structural_chunker.py -v'. By using the testing file (more specifically, using the heading-less document test allows us to confirm that the fix works as intended) The results show that all 15 tests passes when before all tests did not pass.make test-integration)make lint), running 'make lint' introduces no new errors. The same amount of errors that occur in other files still remain the same after implementing the fix, meaning that the new additions do not contribute to more errors.make typecheck)Screenshots / Demo
Notes for Reviewers
For structural_chunker.py, I changed the function test_heading_path_format and test_heading_path_breadcrumb by adding an assertion at the end of each function.