Repository navigation
fix(scraper): measure exclude globs from the scrape root and warn on empty jobs - #649
Merged
Merged
Conversation
… on refresh Adds an async isExcluded admission hook to BaseScraperStrategy. It filters discovered links at enqueue and judges refresh items before they are fetched. A stored page that is excluded is reported as the new PageOutcome.Excluded, and the worker deletes it instead of strategies faking a 404. The base applies include and exclude patterns. LocalFileStrategy adds the includeHidden and followSymlinks rules, which move out of its directory and archive listings.
…e scope A stored page whose content came from a Markdown variant is excluded only when neither its retrieval URL nor its identity is admitted. GitHub repository files are matched by their path in the repository, as discovery does. The local listing keeps its scope check, so members of an HTTP(S) root archive stay out of a web crawl that cannot read them.
WebScraperStrategy decides itself that an HTTP(S) root archive queues no members, so LocalFileStrategy's listings drop their duplicate scope check. Symlink lookups are cached per crawl, GitHub shares one repository-path pattern check, and the E2E tests change stored options through a harness helper.
…empty jobs Match-anywhere exclude globs such as the default `**/test/**` matched the folders at and above the scrape root, so scraping `file:///docs-inbox/test` or `https://example.com/legacy/docs/` indexed nothing. They now match only the path below the root. Anchored globs and regex patterns still match the full URL and absolute path. Patterns are applied in one place, the `getExclusion` admission hook, which returns why a link was rejected. Each rejected link is logged with its reason, and a job that leaves its version without searchable content completes with a warning naming the most common reason. get_job_info, list_jobs and the CLI scrape output show it. The scrape_docs description now explains the default exclude patterns. Applying patterns once also fixes GitHub include patterns, which were re-matched against blob URLs and dropped every file. Closes #624
… in github paths A start URL that redirects is stored under its target. The root now runs first and depth-0 stored pages wait for it, so the patterns never judge the redirected start page. GitHub repository paths whose percent signs are not escapes no longer abort the scrape.
…-mcp-server into fix/624-exclude-pattern-scope # Conflicts: # src/scraper/strategies/GitHubScraperStrategy.ts
Return the rejection straight from evaluateUrlPatterns, share one file-root containment helper, tally rejections in a map, and compute the GitHub tree root once per scrape.
There was a problem hiding this comment.
🟡 Changes recommended
Redirected paths are lost during pattern matching, incorrectly excluding descendants, and refresh exclusions omit rejection reasons, producing misleading warnings.
2 open issues
What changed in this PR
Addresses #624 using the admission hook from #645: scrape-root folder names no longer trigger default exclusions, and empty jobs report warnings.
Changes:
- Centralizes pattern checks and adds root-relative exclusions.
- Reports rejection reasons and exposes empty-job warnings through MCP and CLI.
- Adds regression tests, documentation, and OpenSpec artifacts.
| File | Description |
|---|---|
| test/scrape-patterns-e2e.test.ts | Tests root exclusions and empty-job warnings. |
| test/github-scrape-e2e.test.ts | Tests repository patterns and tree roots. |
| test/cli-e2e.test.ts | Tests CLI warning output. |
| src/tools/ScrapeTool.ts | Returns completion warnings. |
| src/tools/ListJobsTool.ts | Includes job warnings. |
| src/tools/GetJobInfoTool.ts | Exposes warning details. |
| src/store/DocumentStore.ts | Counts stored chunks by version. |
| src/store/DocumentManagementService.ts | Exposes chunk counting. |
| src/scraper/utils/scope.ts | Calculates pattern root directories. |
| src/scraper/utils/scope.test.ts | Tests pattern roots. |
| src/scraper/utils/patternMatcher.ts | Implements reasoned, root-relative matching. |
| src/scraper/utils/patternMatcher.test.ts | Tests matching and rejection reasons. |
| src/scraper/utils/linkRejection.ts | Formats rejection reasons. |
| src/scraper/types.ts | Defines rejection summaries. |
| src/scraper/strategies/WebScraperStrategy.ts | Routes pattern checks through admission. |
| src/scraper/strategies/PyPiScraperStrategy.ts | Returns scrape summaries. |
| src/scraper/strategies/NpmScraperStrategy.ts | Returns scrape summaries. |
| src/scraper/strategies/LocalFileStrategy.ts | Reports hidden-file and symlink exclusions. |
| src/scraper/strategies/GitHubWikiProcessor.ts | Removes unused pattern checking. |
| src/scraper/strategies/GitHubScraperStrategy.ts | Matches repository paths through admission. |
| src/scraper/strategies/GitHubScraperStrategy.test.ts | Moves pattern coverage to E2E tests. |
| src/scraper/strategies/BaseScraperStrategy.ts | Centralizes admission and tallies rejections. |
| src/scraper/strategies/BaseScraperStrategy.test.ts | Tests rejection logs and counts. |
| src/scraper/ScraperService.ts | Returns strategy summaries. |
| src/pipeline/types.ts | Adds the job warning field. |
| src/pipeline/PipelineWorker.ts | Generates empty-version warnings. |
| src/pipeline/PipelineManager.ts | Publishes warnings before completion. |
| src/pipeline/PipelineManager.test.ts | Updates scrape-summary mocks. |
| src/mcp/mcpServer.ts | Describes defaults and displays warnings. |
| src/mcp/mcpServer.test.ts | Tests default-exclusion descriptions. |
| src/cli/commands/scrape.ts | Prints warnings instead of success. |
| openspec/changes/fix-exclude-pattern-scope/tasks.md | Records implementation tasks. |
| openspec/changes/fix-exclude-pattern-scope/specs/scrape-url-patterns/spec.md | Specifies pattern behavior. |
| openspec/changes/fix-exclude-pattern-scope/specs/scrape-job-warnings/spec.md | Specifies warning behavior. |
| openspec/changes/fix-exclude-pattern-scope/proposal.md | Defines purpose and scope. |
| openspec/changes/fix-exclude-pattern-scope/design.md | Documents implementation decisions. |
| openspec/changes/fix-exclude-pattern-scope/.openspec.yaml | Adds change metadata. |
| docs/guides/basic-usage.md | Explains exclusions and warnings. |
| docs/concepts/refresh-architecture.md | Documents the updated admission hook. |
Review effort: Balanced
…t refresh exclusions A depth-0 redirect into a folder such as /docs/test/ no longer lets **/test/** drop its pages. A stored page that a refresh removes is now logged and counted with its reason, so the empty-job warning names it.
…same pages A crawl now judges the URL a redirected page is stored under by the rule a refresh applies, so the next refresh no longer deletes it. Pages about to be excluded wait for the root, at any depth, so a start page that redirects onto a stored child page is kept. Also drops a dead internal-root branch, reattaches the GitHub class doc and tests default discovery of hidden files, symlinks and hidden archive entries.
… on refresh A refresh queued every stored page without running the filters a crawl applies to discovered links, so pages the current options would not admit stayed indexed. An async isExcluded admission hook on BaseScraperStrategy now judges discovered links at enqueue and stored pages before they are fetched, and an excluded stored page is reported as PageOutcome.Excluded and deleted. - The base hook applies include and exclude patterns. A stored page with a Markdown source is excluded only when neither URL is admitted, and the start page is never excluded, including where its URL redirected. - A crawl judges redirect targets by the same rule, so a scrape and a refresh store the same pages. - LocalFileStrategy excludes hidden paths and symlinks below the crawl root per includeHidden and followSymlinks, cached per crawl. - GitHubScraperStrategy matches repository files by their repository path. - An HTTP(S) root archive queues no file:// members.
…-mcp-server into fix/624-exclude-pattern-scope # Conflicts: # src/scraper/strategies/BaseScraperStrategy.ts # src/scraper/strategies/LocalFileStrategy.ts
…-mcp-server into fix/624-exclude-pattern-scope # Conflicts: # docs/concepts/refresh-architecture.md # src/scraper/strategies/BaseScraperStrategy.ts # src/scraper/strategies/GitHubScraperStrategy.ts # src/scraper/strategies/LocalFileStrategy.ts
…-mcp-server into fix/624-exclude-pattern-scope # Conflicts: # docs/concepts/refresh-architecture.md # src/scraper/strategies/BaseScraperStrategy.ts # src/scraper/strategies/GitHubScraperStrategy.ts # src/scraper/strategies/LocalFileStrategy.ts # test/github-scrape-e2e.test.ts # test/local-file-refresh-e2e.test.ts # test/refresh-pipeline-e2e.test.ts
…do not name Include patterns name files, so a local crawl with includePatterns such as **/*.md never entered sub/. Folders and archives are now judged by the exclude patterns only, during a scrape and a refresh alike.
…from the fetched start url A concurrent refresh judged stored pages before the root's redirect was known and could delete pages a fresh scrape keeps. A Markdown start page measured patterns from its identity rather than its own folder.
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.


Closes #624. Builds on #645, so it targets that branch; it can go to
mainonce #645 is merged.Problem
Scraping a folder named
testindexed nothing, and nothing said why. The default exclude pattern**/test/**was matched against the whole path, so it also matched the scrape root itself (file:///docs-inbox/test) and every link was dropped. The same happens with any root under a default-excluded folder, likehttps://example.com/legacy/docs/. The debug log called each of these links "out-of-scope", and the job reported a plain success.What changes
**/match only below the scrape root. This covers all default folder exclusions and user patterns of the same form. Folders liketest/orarchive/inside the root are still excluded. Anchored globs (/docs/v3/**,https://example.com/docs/**) and regex patterns match the full URL and the absolute path as before.getExclusionbecause it returns why a link was rejected. Before, links went through the patterns twice, and the second pass matched GitHub files by blob URL, so GitHub include patterns likedocs/**dropped every file. They work now.1 link was skipped as excluded by pattern `**/test/**`; default exclude patterns apply unless excludePatterns is set.get_job_info,list_jobsand the CLIscrapeoutput show it. A refresh where every page is unchanged gets no warning.scrape_docsdescription says that default exclude patterns apply unlessexcludePatternsis set, and that any value replaces them.The spec is in
openspec/changes/fix-exclude-pattern-scope/.Behaviour users will notice
test,old,build,legacyand similar now index content.includePatternsnow work, and GitHub repo-path exclude patterns apply when links are queued.Tests
test/scrape-patterns-e2e.test.ts: the/docs-inbox/testreproduction, a web root under/legacy/docs/, links outside the root, the warning throughget_job_info, and no warning on an unchanged refresh.test/github-scrape-e2e.test.ts:includePatterns: ["docs/**"]indexesdocs/files; atree/main/testroot keeps its files.test/cli-e2e.test.ts: the CLI prints the warning instead of success.npm run lint, a coldnpm run typecheck,npm run buildandnpm testpass.Not in this PR