Content ingestion and enrichment jobs
Content ingestion and enrichment jobs turn a saved bookmark into useful stored content. The worker system fetches and parses web pages, extracts text from files, adds summaries and tags, creates vector data, and keeps search results current. This page is a child of Background processing pipeline; see Search, inference, and plugin architecture for shared service boundaries and Search and vector retrieval for discovery behavior.
Content processing lifecycle
The lifecycle starts with a bookmark or feed entry and ends with records that support reading, search, and similar-content discovery. Each stage writes its own result and can start the next stage through a queue, so a slow or optional stage does not block the whole process.
The main paths are:
- A link bookmark goes to the crawler. The crawler stores page content and page assets, then starts enrichment and indexing.
- An image or PDF bookmark goes to asset preprocessing. That worker extracts text and may create a PDF preview before it starts enrichment and indexing.
- A crawled link can start a video job when video download is enabled.
- A feed refresh creates link bookmarks for new feed entries. Those bookmarks then use the normal link processing path.
- Enrichment updates the bookmark. Search indexing then publishes the current bookmark view to search and vector systems.
The following diagram shows how saved content moves through the main worker paths.
flowchart TD
A[Saved bookmark] --> B{Content kind}
B -->|Web link| C[Crawler]
B -->|Image or PDF| D[Asset preprocessing]
C --> E[Stored content and assets]
D --> E
C --> F[Optional video download]
E --> G[Embedding generation]
E --> H[Summary and tag inference]
E --> I[Search indexing]
G --> J[Vector store]
H --> I
I --> K[Search index]
L[RSS feed refresh] --> M[New link bookmarks]
M --> C
Queue boundaries
Each stage accepts a small job request that identifies the bookmark or feed. The queue definitions provide the contract between producers and workers. They also give later work the same user group and priority when one job starts another. See Queue execution backends for how these requests run.
The crawler and enrichment stages use separate queues. This separation limits the effect of browser work, model calls, file parsing, and index updates on one another. A missing optional service usually lets the worker finish without producing that optional result.
References: packages/…/queues.ts• L80-190 packages/…/queues.ts• L231-290 apps/…/index.ts• L43-92
Web content ingestion
The crawler is the main path for link bookmarks. It first probes the URL to choose webpage or asset handling and to collect early preview metadata. It then fetches a rendered page or a stored archive, resolves page metadata, extracts readable content, and stores the content and related assets on the bookmark.
The crawler treats a URL that points to a supported image or PDF as an asset bookmark instead of a web page. It saves the file, changes the bookmark kind, and starts asset preprocessing so the same enrichment path can handle the new content.
Page capture
Page capture first makes metadata available, then persists the larger content and asset records. The probe can write a title, description, image, or favicon while the browser crawl runs. Its write only fills empty fields, so a late probe result cannot replace metadata from a completed retry. The final crawl merges probe data when the rendered page looks blocked.
The crawler also protects the source fetch from common operational problems. It applies domain rate limits, keeps one proxy choice for a run, retries selected bad responses, and prefers probe metadata when the rendered response looks like a block page. Asset writes enforce size and storage limits. Inline data-URI images are decoded locally only for supported image types and remain subject to those limits. Downloaded files are streamed through the size limit, and an aborted crawl remains retryable. Large HTML content is stored as an asset instead of inline bookmark content. A later archival step can store a full-page copy when the feature is enabled, but oversized archives are discarded before storage.
References: apps/…/crawlerWorker.ts• L205-257 apps/…/crawlerWorker.ts• L259-329 apps/…/crawlerWorker.ts• L384-479 apps/…/probe.ts• L59-70 apps/…/probe.ts• L141-208 apps/…/probe.ts• L213-314 apps/…/crawlAndParse.ts• L174-181 apps/…/crawlAndParse.ts• L225-351 apps/…/crawlAndParse.ts• L395-529 apps/…/assetStorage.ts• L149-223 apps/…/assetStorage.ts• L225-344 apps/…/assetStorage.ts• L369-493 apps/…/assetStorage.ts• L496-575
Asset preprocessing
Asset preprocessing makes uploaded or downloaded files useful to the rest of the system. It reads the stored image or PDF, saves extracted text as bookmark content, and creates a first-page screenshot for PDFs.
Image text can come from local OCR or from an image-capable inference service. If the configured image service is not available, the worker falls back to local OCR. PDF text comes from the document itself, while the PDF metadata can remain available as supporting asset data. An initial preprocessing run starts enrichment and search work after it handles the asset; a repair run starts that work only when it adds text or a preview.
File-derived content
The worker handles files after the asset record exists. A missing bookmark, a missing asset, or an unsupported asset kind is a job error. Storage quota checks can cause an optional preview or downloaded asset to be skipped without treating the whole content flow as successful page capture.
References: apps/…/assetPreprocessingWorker.ts• L122-187 apps/…/assetPreprocessingWorker.ts• L189-277 apps/…/assetPreprocessingWorker.ts• L280-337 apps/…/assetPreprocessingWorker.ts• L339-374 apps/…/assetPreprocessingWorker.ts• L386-466 apps/…/assetPreprocessingWorker.ts• L468-506
Video capture
Video capture is an optional follow-up to a successful link crawl. It validates the link's redirects through the network safeguards, attempts to obtain a supported video file, checks the user's storage quota, and replaces the bookmark's earlier video asset with the downloaded file.
The job is separate because media download has different time and resource needs from page capture. Unsupported media URLs, invalid redirects, and quota limits are handled as skips. Failed downloads remove temporary files so an incomplete media file does not remain as a saved asset.
Media asset replacement
The video worker saves the new file and updates the bookmark's asset relation as one database operation. It removes the prior file only after the new relation is in place. This keeps the bookmark tied to a complete asset when a replacement succeeds.
References: apps/…/crawlerWorker.ts• L308-317 apps/…/videoWorker.ts• L101-135 apps/…/videoWorker.ts• L137-183 apps/…/videoWorker.ts• L185-237
AI enrichment
AI enrichment adds a short summary and inferred tags to a bookmark. The inference worker selects the requested operation, loads the bookmark's content, and sends it to the configured inference service. The result is saved on the bookmark and can trigger a new search index update.
The crawler and asset preprocessing worker start this work after useful content is available. When automatic vector indexing is enabled, embedding generation starts first and passes its vector to tagging. Tagging can then use similarity context before the new bookmark reaches the vector index.
Embedding generation
An embedding is a numeric representation of bookmark content used to find related records. The embedding worker builds input from the bookmark's title, type, tags, notes, summary, source details, metadata, and a bounded content excerpt. It then separates vector generation from vector storage.
The generated vector starts two independent outcomes: an indexing job writes it to the vector store, and a tagging job can use it at once. For that fast path, tagging searches the vector store with the new vector. It limits results to the same user, removes the current bookmark, and uses only sufficiently similar neighbors. If no new vector is available, tagging uses the bookmark's existing vector-index record instead. A vector-store or embedding-client absence does not prevent ordinary tagging from running. A permanent embedding failure also falls back to tagging without similarity context.
References: apps/…/embeddingsWorker.ts• L256-344 apps/…/embeddingsWorker.ts• L348-391 apps/…/embeddingsWorker.ts• L394-498 apps/…/tagging.ts• L536-590 packages/…/vectorStore.ts• L5-18
Summary and tag inference
Summarization produces free-form text for the bookmark. Tag inference connects generated or user-curated tags to the bookmark and can use similar bookmarks to suggest relevant tags. Both results update the bookmark's enriched state and lead to a fresh search index request.
User settings can disable or shape these operations. Tagging accepts text, extracted file text, or an image as its input. Missing content causes the relevant operation to stop without inventing a result. A configured inference client is required for model-backed work; without one, the worker has no enrichment result to save. When tagging follows a new embedding, it can use that vector to find related tags before the vector store contains the bookmark. The similarity lookup is limited to the bookmark owner's records, so tags from another user do not enter the prompt.
References: apps/…/inferenceWorker.ts• L21-42 apps/…/inferenceWorker.ts• L83-123 apps/…/summarize.ts• L160-192 apps/…/tagging.ts• L92-140 apps/…/tagging.ts• L307-412 apps/…/tagging.ts• L629-737
Search and vector indexing
Indexing publishes the latest bookmark state to two discovery systems. The search worker builds a document from the bookmark's source data, extracted content, notes, summary, and tags. The embeddings worker publishes the numeric representation used for similar-content queries.
The search document is rebuilt from the database at job time rather than copied from the producer's request. This means a later summary, tag, or asset-text change can replace the earlier search view. Delete jobs remove a bookmark from the search index, while delete embedding jobs remove its vector.
Discovery records
Search and vector records include the user identity needed to keep results within the correct user's scope. Search supports text queries and ordered results. Vector retrieval supports nearest-neighbor search and similar-bookmark lookup. See Search and vector retrieval for the shared discovery contracts and clients.
References: apps/…/searchWorker.ts• L63-134 apps/…/searchWorker.ts• L136-176 packages/…/search.ts• L5-25 packages/…/vectorStore.ts• L26-83
Feed ingestion
The feed worker turns new RSS entries into link bookmarks. A scheduler checks enabled feeds each hour and spreads their jobs across the hour instead of fetching all feeds at once. Each feed job checks bookmark quota, fetches and validates XML, parses entries, and keeps only entries not seen before.
New entries are created through the bookmark service, which lets them enter the normal crawler and enrichment flow. See Bookmark and organization APIs for the service boundary used by this step. Feed categories can become tags when feed tag import is enabled. A feed import record keeps the entry identity so the next refresh does not create the same bookmark again.
Feed refresh scheduling
Feed status records the latest fetch result and time. A successful parse also records the last successful fetch time. A fetch, response, content-type, or parse failure is recorded as a failed refresh and waits for the next scheduled run rather than blocking other feeds.
References: apps/…/feedWorker.ts• L22-35 apps/…/feedWorker.ts• L60-113 apps/…/feedWorker.ts• L167-269 apps/…/feedWorker.ts• L271-380 apps/…/feedParser.ts• L19-42
Change checklist
When these files or sections are changed, remember to consider these:
- Keep each queue schema aligned with both its producer and worker. In particular, preserve the distinct embedding operations for generation, storage, and deletion.
- If bookmark fields or content sources change, update both the search document build and the embedding text build. They read related data but serve different discovery systems.
- If crawler or asset preprocessing output changes, check every downstream enqueue path for tagging, summarization, embeddings, and search reindexing.
- If probe metadata changes, preserve the fill-only early write and the merge with final crawl metadata. Probe work can finish after a failed attempt or after a retry.
- If crawler asset handling changes, keep data-URI decoding and image-type checks, streamed download limits, archive-size limits, quota checks, abort propagation, and temporary-file cleanup aligned.
- If feed identity or parsing rules change, preserve the link between feed entry IDs and import records or refreshes can create duplicates.
- If asset replacement changes, keep the database relation and stored file lifecycle aligned so a failed replacement cannot leave a dangling record.
- If embedding-to-tagging handoff changes, preserve the user filter and the distinction between searching with a fresh vector and finding similar indexed bookmarks.
- If a worker is added or renamed, update its queue initialization and worker selection in apps/…/index.ts. Review Automation and operations jobs if the work belongs to imports, rules, webhooks, backups, or maintenance instead of content enrichment.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A crawler receives a blocked response or challenge page | Page metadata can be polluted by the block page or the crawl can fail after its retry limit | Probe metadata is preferred for blocked renders. Selected status codes use queue retries. |
| A detached probe write finishes after a retry stores final metadata | Early preview data can overwrite the result of the successful crawl | Probe writes fill empty fields only. The final crawl owns its metadata merge. |
| A link points to an image or PDF but the required file download fails | The link cannot become an asset bookmark, so asset enrichment does not start | The crawler treats the required download as a job error instead of creating an incomplete asset relation. |
| A PDF has no extractable text | Asset preprocessing fails and pending enrichment states are cleared after permanent failure | The worker checks for extracted PDF text before saving it. |
| A downloaded asset exceeds the size limit or the user's quota | The optional asset is skipped and the related bookmark may have less stored media | Downloads enforce a byte limit before save. Storage checks run before each asset write. |
| A data URI is malformed, too large, or declares an unsupported image type | The banner or other inline image is skipped without creating an unsafe or oversized asset | The crawler checks encoded size before decode, allows only supported image types, checks decoded size, and applies the user's quota. |
| A crawler timeout aborts an in-progress file download | The crawl is retried instead of being reported as a successful crawl with a missing asset | The download rethrows the abort after cleanup so the queue runner observes the cancellation. |
| A full-page archive exceeds its configured size limit | The archive is discarded and the bookmark keeps its other captured content | The crawler checks the generated archive size before the quota check and storage step. |
| A video URL has an invalid redirect or no supported media | The optional video asset is not added to the bookmark | Redirects are validated before the media tool runs. Unsupported media is treated as a skip. |
| No vector store or embedding client is configured | Vector discovery is unavailable and a generated vector cannot be stored | The worker skips vector work and can enqueue tagging without vector context. |
| The vector lookup for related tags fails | Tagging still runs but the model receives no similar-bookmark tag context | Related-tag lookup is optional and its failure is logged without failing the tagging job. |
| A feed entry has no usable link or stable identity | The entry is not imported as a bookmark | Parsing normalizes an entry ID, GUID, or link into its identity, and import requires both identity and link. |
| Search indexing runs after a bookmark was deleted | The index job finds no bookmark and leaves the external index unchanged | Deletion must enqueue the search delete operation as part of the bookmark deletion path. |
Key files
| File | Why to read it |
|---|---|
| apps/…/index.ts | Shows which content workers start and how their queues are initialized. |
| apps/…/crawlerWorker.ts | Shows the crawler entry point and the follow-up jobs created after a crawl. |
| apps/…/probe.ts | Shows early content-type routing and safe preview metadata handoff across crawl retries. |
| apps/…/crawlAndParse.ts | Shows how page content, metadata, and assets become saved bookmark data. |
| apps/…/assetStorage.ts | Shows how crawled files, inline data-URI images, large page content, and page archives pass size, cancellation, and quota checks before storage. |
| apps/…/assetPreprocessingWorker.ts | Shows how image and PDF files become text and preview data. |
| apps/…/embeddingsWorker.ts | Shows the split between embedding generation, tagging handoff, and vector storage. |
| apps/…/inferenceWorker.ts | Shows the common entry point for summary and tag enrichment. |
| apps/…/tagging.ts | Shows how tags use bookmark content and related bookmarks, then trigger downstream updates. |
| apps/…/searchWorker.ts | Shows how current bookmark data becomes a search document or is removed from search. |
| apps/…/videoWorker.ts | Shows the optional media download and asset replacement path. |
| apps/…/feedWorker.ts | Shows scheduled feed refresh and creation of new link bookmarks. |
| packages/…/queues.ts | Defines the job contracts and the boundaries between producers and workers. |
| packages/…/search.ts | Defines the search document and search index contract used by the search worker. |
| packages/…/vectorStore.ts | Defines the vector document and similar-content contract used by embedding work. |