Repository navigation
feat(scraper): delete stored pages the scrape options no longer admit on refresh - #645
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues can delete valid pages during refresh, retain excluded GitHub files, and fail HTTP(S) archive scrapes with ENOTDIR errors.
3 open issues
What changed in this PR
This PR makes refresh delete stored pages that current scrape filters exclude, using a shared admission hook rather than simulated 404 responses.
Changes:
- Adds an
Excludedoutcome and stored-page deletion handling. - Centralizes local hidden-file and symlink filtering.
- Adds refresh regression tests and updates architecture documentation.
| File | Description |
|---|---|
| test/refresh-pipeline-e2e.test.ts | Tests exclusion without fetching. |
| test/local-file-refresh-e2e.test.ts | Tests hidden-file and symlink removal. |
| src/scraper/types.ts | Defines the excluded outcome. |
| src/scraper/strategies/LocalFileStrategy.ts | Centralizes local admission rules. |
| src/scraper/strategies/BaseScraperStrategy.ts | Checks admission during discovery and refresh. |
| src/pipeline/PipelineWorker.ts | Deletes and logs excluded pages. |
| docs/concepts/refresh-architecture.md | Documents admission and deletion behavior. |
| ARCHITECTURE.md | Updates the outcome list. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Critical issues remain: malformed percent escapes can abort entire GitHub scrapes, and redirected-root refreshes can delete the stored start page despite unchanged options.
2 open issues
3 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Two critical scraper issues remain: queued processing can delete the resolved root, and Markdown 404 fallback can discard a valid admission decision and delete a still-live page.
2 open issues
2 resolved since last review
Review effort: Balanced
1c520b0 to
d1aeb94
Compare
… 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.
d1aeb94 to
67581d8
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Refresh filtering still misdecodes literal-percent GitHub filenames and ignores local ancestor include patterns, causing valid pages to be deleted or excluded pages to be retained.
2 open issues
4 resolved since last review
Review effort: Balanced


Why
A refresh queues every stored page without running the filters a crawl applies to the links it finds. So a page the crawl would no longer admit stays in the index. For example, it now matches
excludePatterns, it is hidden andincludeHiddenwas turned off, or it sits behind a symlink andfollowSymlinkswas turned off. Before this change, the symlink and hidden cases did worse than keep the page: the access policy threw while the page was fetched, which failed the refresh unlessignoreErrorswas set.This came up in the review of #467. There, deleting newly gitignored files on refresh has to pretend they answered 404, because the base strategy has no shared way to say "this page is now excluded".
What
BaseScraperStrategy.isExcluded(url, options, context): a new async, protected admission hook.shouldProcessUrl.pageId) before anything is fetched.PageOutcome.Excluded: an excluded stored page is reported with this outcome anddeleted: true.PipelineWorkerdeletes it through the existingremoveDeletedPage/DocumentStore.deletePagepath and logs the removal at info level.DocumentStoreneeds no change. Like a refresh 404, an exclusion does not count towardabortOnFailureRate.LocalFileStrategy.isExcludedadds two rules for paths below the crawl root:includeHiddenis on;followSymlinksis on.These rules used to live in the directory listing and in
isVisibleArchiveEntry. They moved into the hook, so a scrape and a refresh admit pages by the same rule. Members of an archive expanded under an internal root are judged from that root and skip the symlink check, which matches the access policy's bypass for them.Docs:
docs/concepts/refresh-architecture.mdhas a new Admission section and the updated outcome diagram.ARCHITECTURE.mdlists the new outcome.I deliberately did not add rules for the access-policy mode or
allowedRoots. If someone disables file access or a configured root is unmounted, deleting the whole index on the next refresh would be far worse than failing the job, and failing the job is what happens today.Tests
The E2E tests run through
usePipelineHarness. Each one scrapes, changes the config, refreshes, and then checksstoredUrls()and the outcome:test/refresh-pipeline-e2e.test.ts: the storedexcludePatternschange, and the newly excluded page is deleted without being requested.test/local-file-refresh-e2e.test.ts:includeHiddenis turned off, and both a hidden file and a file inside a hidden folder are deleted.test/local-file-refresh-e2e.test.ts:followSymlinksis turned off, and both a symlinked file and a file under a symlinked folder are deleted, while the real file stays.npm run lint, a coldnpm run typecheckandnpm test(afternpm run build) all pass locally.Moving #467 onto the hook
Once both PRs are merged,
respectGitignoremoves intoLocalFileStrategy.isExcluded:gitignoredResult(), and the gitignore checks inprocessItemand in the directory listing, then go away. A gitignored stored page gets reported asExcludedinstead of a fakeNOT_FOUND. A gitignored path found mid-crawl is never queued, so it no longer counts as a processed item that produced nothing. I can do this as a follow-up commit after #467 merges.