fix(ingestion): match navigation "header" by class token, not substring - #241
Open
detail-app[bot] wants to merge 1 commit into
Open
Conversation
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.
Detail bug report: View on Detail
Bug
HtmlContentExtractor.isNavigationElementflagged any element whoseclassattribute contained the substring"header"as navigation. That over-matched content wrappers whose class token merely ends inheader—page-header,card-header,section-header,subheader— so when one was a direct child of the selected content element,appendFormattedChildskipped it and dropped the nested heading. The heading never reached chunking or either encoder, so it was absent from both the dense and lexical/sparse vectors (and from the chunk-text portion of the reranker prompt). The same "remove header" intent is implemented elsewhere in the file as the CSS selector.header, which matches the whole tokenheaderand does not matchpage-header— so the two paths diverged exactly on the*-headercontent wrappers.Fix
Narrow only the
headercheck to a whole class-token match (classTokens.contains("header")overelement.classNames()), leavingnav/menu/sidebar/footeras substring checks. This alignsisNavigationElement's header semantics with the existing.headerselector. Composite nav classes (top-nav,main-nav,header-nav,primary-nav) stay caught by the unchangedclassName.contains("nav"), so genuine navigation is still removed;*-headercontent wrappers, which have no navigational reading, now survive and carry their nested headings through to chunking.Testing
HtmlContentExtractorTest:pageHeaderWrapperRetainsNestedHeading— a direct-child<div class="page-header"><h1>…</h1></div>retains the heading.exactHeaderClassTokenIsStillRemoved—<div class="header">is still dropped, preserving the intended "remove header" behavior.compositeNavClassesAreStillRemoved—top-nav/main-nav/header-nav/primary-navare still removed, pinning the asymmetry (onlyheaderwas narrowed).make test(17 shell contract scripts), and the lint lane (Spotless/PMD/SpotBugs, ast-grep rules, ruby SSOT check). The 10 pre-existing extractor tests, including the Javadocclass="header"fixtures, stay green./v1/embeddingsendpoint, booted the backend in local-embedding mode, and ingested a crafted page whose only occurrence of a distinctive term sat inside a direct-child<div class="card-header"><h2>…</h2></div>. The resulting Qdrantdocschunk's stored text contained the distinctive heading term — the heading survived extraction, was chunked, was passed to both encoders, and was upserted. Under the old code that wrapper would have been dropped as navigation and the chunk would have held only the sibling body prose.JavaApiPageExtractorTestdoesn't exist in the repo, so that targeted run found no such test class. The Javadoc exact-token.headerpath it would cover is exercised by the existing Java API page fixtures (extractsModernClassMembersWithTheirExactDomAnchorsInSourceOrder,retainsPackagePagesAsUnanchoredJavaApiOverviews, etc.), which stay green.Closes #228
Automatic Fixes PRs can be configured here.