Skip to content

fix(import): RM-17387 Sitemap fallback creates sparse imports#30

Draft
xavierandueza wants to merge 1 commit into
mainfrom
fix/rm-17387-ai-importer-cerqlar-investigate-why-import-only-got-1-page
Draft

fix(import): RM-17387 Sitemap fallback creates sparse imports#30
xavierandueza wants to merge 1 commit into
mainfrom
fix/rm-17387-ai-importer-cerqlar-investigate-why-import-only-got-1-page

Conversation

@xavierandueza

Copy link
Copy Markdown
Contributor
🚥 Resolves RM-17387

🧰 Changes

  • BEFORE: sitemap fallback could over-scope imports to the originally supplied path, causing sparse routes like /learn to produce a one-page skeleton.
  • AFTER: sitemap fallback can discover well-known docs sitemap locations and root sitemap results before conservative docs-subtree narrowing.
  • Ambiguous routes such as /learn are no longer treated as strong docs-only scopes.

🧬 QA & Testing

  • node --test src/commands/import.test.js
  • npm test

[RECORDING/IMAGES]

@xavierandueza xavierandueza self-assigned this Jul 10, 2026

@xavierandueza xavierandueza left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code-quality pass: the behavior direction makes sense, but I think the sitemap fallback needs a cleaner shape before this lands. The current implementation adds more serial orchestration and duplicates the docs-subtree narrowing model instead of extracting the shared policy.

Comment thread src/commands/import.js
const seenUrls = new Set()

for (const candidate of buildSitemapCandidates(sourceUrl)) {
const res = await fetchSitemap(candidate.url)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This changes sitemap fallback from "try candidates until one works" into "fetch every candidate", but keeps the network work strictly sequential. These probes are independent, and this path now includes every well-known docs route plus the source-path walk-up; on a site where most candidates 404/timeout, import latency becomes the sum of all failures.

Can we restructure this as bounded/parallel discovery that preserves candidate order when aggregating results? That would make the new gather-first model explicit without turning fallback into a long serial chain. The existing llms route probing already uses Promise.all, so keeping sitemap discovery serial feels like avoidable orchestration complexity rather than a necessary control flow.

Comment thread src/commands/import.js
})
if (!rootHit) return null

const firstSegs = new Set()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This duplicates the same docs-root segment detection/filtering policy that narrowToDocsSubtreeIfNeeded implements for llms.txt above. The two flows now need to stay manually aligned on: host docs exemption, root-hit gating, first-segment extraction, DOCS_LIKE_ROOT_SEGMENTS, prefix matching, and malformed URL handling.

I think the code-judo move here is to extract the policy, not reimplement it for a second input shape. For example: normalize llms items and sitemap URLs into a simple URL list, run a shared findDocsLikeRootSegment(...) / filterUrlsToRootSegment(...), then let each caller adapt the result back to its shape. That deletes a lot of duplicated branching and keeps future scope tweaks from drifting between llms and sitemap fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant