Automation and operations jobs
Automation and operations jobs carry out work that should not delay a user request. They apply bookmark rules, import external collections, create account backups, notify external systems, and repair shared data through bounded background tasks. These workers extend the background processing model beyond content capture and enrichment. The queue execution backends page explains how their jobs are scheduled and run.
Job responsibilities
Each worker owns one kind of delayed responsibility and changes a durable result or an external system. Producers place typed work on a queue, while the worker checks the current data before it acts. This keeps a later job from relying only on a stale request payload.
| Worker | Responsibility | Main result |
|---|---|---|
| Rule engine | Evaluate bookmark and organization events against enabled user rules | Tags, lists, archive state, favourite state, or a request for a full-page archive |
| Import | Turn staged external records into bookmarks and track each result | Completed, rejected, duplicate, or still-processing import items |
| Backup | Build a complete account archive and enforce retention | A downloadable backup asset and a success or failure record |
| Webhook | Deliver subscribed bookmark events to external URLs | External event delivery with retry attempts |
| Administrative maintenance | Run named data repair and cleanup tasks | Reconciled asset records or migrated stored content |
These jobs share the same queue lifecycle as the other workers. They can be delayed, retried, limited by capacity, and stopped through the worker process. Integration and operations APIs describes the user and administrator actions that start or inspect many of these jobs.
References: packages/…/queues.ts• L193-229 packages/…/queues.ts• L293-337 apps/…/index.ts• L43-92
Rule automation
The rule engine turns changes to a bookmark or its organization into repeatable user actions. A rule combines an event, a condition, and one or more actions. The event starts evaluation, the condition decides whether the bookmark matches, and the actions update organization state or request more background work.
Rules can respond to bookmark creation, tag changes, list membership changes, favouriting, and archiving. Conditions can inspect the bookmark's type, source, URL, title, feed, tags, and state. Actions can add or remove tags or lists, archive or favourite a bookmark, or request a full-page archive. Rules and the resources they name remain within one user's scope. See Bookmark and organization APIs for the user-facing rule model.
The application first checks whether an enabled rule could match an event. Only a possible match creates a rule-engine job. The worker then loads the bookmark and the user's rules, evaluates each event, and runs matching actions. A missing bookmark is a no-op because there is no current state to change.
flowchart LR
A[Bookmark or list change] --> B[Possible rule match]
B -->|No match| C[No job]
B -->|Match| D[Rule engine job]
D --> E[Load current bookmark and rules]
E --> F{Event and condition match?}
F -->|No| G[No action]
F -->|Yes| H[Run rule actions]
H --> I[Update tags, lists, or bookmark state]
H --> J[Queue optional page archive]
References: packages/…/ruleEngine.ts• L87-155 packages/…/ruleEngine.ts• L158-174 apps/…/ruleEngineWorker.ts• L59-113 packages/…/rules.ts• L48-68 packages/…/rules.ts• L168-221
Import processing
Import processing moves an external bookmark collection into the normal bookmark system without making the upload request create every bookmark at once. An import session is a durable record with staged items, progress counts, and controls for pause, resume, finalization, and result review.
The client stages valid link, text, or asset records in an open session. Finalization makes the session eligible for the import worker. The worker claims pending rows in small batches, shares capacity fairly across users, and creates bookmarks through the normal bookmark service. It applies tags and list membership after creation, so imported records use the same downstream crawl, tagging, indexing, and rule paths as ordinary bookmarks.
The worker treats duplicate links as completed skips rather than new bookmarks. Link and text records can be accepted, while asset records are currently rejected as unsupported. Accepted items remain in processing until downstream crawl and tagging work reaches a terminal state. Stale claims without a created bookmark return to pending so a later poll can retry them.
sequenceDiagram
participant Client
participant Session as Import session
participant Worker as Import worker
participant Bookmark as Bookmark services
participant Downstream as Crawl and tagging jobs
Client->>Session: Stage records
Client->>Session: Finalize session
Session->>Worker: Expose pending rows
Worker->>Worker: Claim a fair batch
Worker->>Bookmark: Create or find bookmark
Bookmark-->>Worker: Accepted, duplicate, or error
Worker->>Downstream: Start normal processing for accepted item
Downstream-->>Worker: Reach success or failure state
Worker->>Session: Record item and session result
The import worker also archives completed sessions after their retention period. It reports item and session states so a client can tell the difference between work that is waiting, still running, completed, rejected, or paused. See Content ingestion and enrichment jobs for the downstream content work that an accepted link enters.
References: packages/…/importSessions.ts• L54-162 packages/…/importSessions.service.ts• L74-164 apps/…/importWorker.ts• L115-175 apps/…/importWorker.ts• L177-261 apps/…/importWorker.ts• L379-513 apps/…/importWorker.ts• L524-745
Backup creation
Backup jobs create a restorable account snapshot as a downloadable archive. A user request creates a pending backup record and queues work. A daily scheduler also queues backups for users who enable daily or weekly backups, spreading scheduled work across the day.
The worker reads the user's lists and bookmarks, writes the export in a bounded stream, compresses it, checks storage quota, and stores the archive as an account asset. It then records the bookmark count, size, asset identity, and final status. Temporary files are removed after success or failure. Old backups are deleted according to the user's retention setting after a successful backup.
flowchart TD
A[Manual or scheduled request] --> B[Pending backup record]
B --> C[Backup queue]
C --> D[Export lists and bookmarks]
D --> E[Compressed archive]
E --> F{Storage quota available?}
F -->|No| G[Failure status]
F -->|Yes| H[Store backup asset]
H --> I[Success status]
I --> J[Remove old backups by retention]
The backup API returns the record before the archive is ready. Clients must use the backup status and download the archive only after success. A failed queue job also updates the backup record when its identity is known, so operational failure is visible in the user-facing record.
References: apps/…/backupWorker.ts• L40-116 apps/…/backupWorker.ts• L118-171 apps/…/backupWorker.ts• L173-318 packages/…/backups.ts• L43-79 packages/…/backups.ts• L14-59
Webhook delivery
Webhook delivery sends bookmark events to destinations that a user has registered. Registration stores a destination and its event selection while keeping the secret token out of public webhook responses. Bookmark operations enqueue delivery only when the user has at least one registered destination.
The worker finds the current bookmark and the user's webhook registrations, keeps only destinations that subscribe to the event, and sends each matching delivery independently. The payload identifies the job, bookmark, user, operation, and available link details. A deleted bookmark is a supported exception because the event can still use the user ID in the job.
Each destination has a request timeout and a bounded retry loop. One destination can fail while another succeeds, and the worker records the delivered and failed counts. The source bookmark operation does not wait for remote systems. See Integration and operations APIs for the registration and API boundary.
flowchart LR
A[Bookmark event] --> B[Webhook queue]
B --> C[Load current subscriptions]
C --> D{Subscribed destinations}
D --> E[Send event to each destination]
E -->|Success| F[Delivered]
E -->|Timeout or error| G[Retry delivery]
G --> E
E -->|Retry limit reached| H[Failed delivery]
References: packages/…/webhooks.service.ts• L77-95 packages/…/queues.ts• L293-308 apps/…/webhookWorker.ts• L61-85 apps/…/webhookWorker.ts• L86-184 packages/…/bookmarks.ts• L545-564
Administrative maintenance
Administrative maintenance provides controlled repair work for data that spans stored files and database records. An administrator queues a named task instead of running a large scan in the request path. The maintenance worker validates the task type and runs one task at a time.
The current tasks have separate purposes:
- Asset tidying checks stored assets against database rows. It can remove dangling stored assets and can refresh database metadata from the stored file.
- Large HTML migration moves link HTML that is above the configured size threshold from an inline field into a content asset. It checks quota and updates the bookmark relation with the stored asset.
The task boundary is intentionally narrow. Other administrator repair actions, such as recrawling links or rebuilding search and embedding state, enqueue work on the worker that owns that state rather than on the maintenance worker. Queue statistics expose maintenance pressure alongside the other background workloads. See Integration and operations APIs for the administrator controls.
flowchart TD
A[Administrator request] --> B[Maintenance queue]
B --> C{Task type}
C -->|Tidy assets| D[Check stored assets and metadata]
C -->|Migrate large HTML| E[Move inline HTML to content asset]
D --> F[Reconciled asset state]
E --> F
References: packages/…/admin.ts• L205-218 packages/…/admin.ts• L265-470 packages/…/admin.ts• L466-470 apps/…/adminMaintenanceWorker.ts• L17-93 apps/…/tidyAssets.ts• L14-80 apps/…/migrateLinkHtmlContent.ts• L28-55 apps/…/migrateLinkHtmlContent.ts• L57-149
Operational boundaries
These workers use different forms of durable state because their work has different completion signals. Rule results are log and state changes, import results are item and session statuses, backups have records and archive assets, webhooks have delivery outcomes, and maintenance jobs rely on queue completion plus logs and metrics.
The worker process starts only the enabled worker set. Queue-backed workers are initialized before queue execution starts. The import worker is a polling loop rather than a queue runner, and the backup scheduler starts only when the backup worker is enabled. This means a deployment can omit one responsibility without changing the contracts of the others.
For queue capacity, retry behavior, priorities, and backend differences, follow Queue execution backends. For the full set of content-related workers that these jobs may start or wait for, follow Content ingestion and enrichment jobs.
References: apps/…/index.ts• L43-105 apps/…/index.ts• L108-176 packages/…/queues.ts• L193-229 packages/…/queues.ts• L293-337
Change checklist
When these files or sections are changed, remember to consider these:
- Keep event names aligned across bookmark and list producers, rule matching, webhook matching, and the shared queue payloads. A renamed event can silently stop both kinds of automation.
- Keep rule conditions and actions aligned with ownership checks and with the resource operations that actions call. A valid rule must not point at a tag or list that its user cannot use.
- Keep import session states aligned across staging, finalization, pause and resume, worker claims, downstream completion, and result reporting. A state that does not reach a worker-eligible status can strand an import.
- Keep backup status, backup asset ownership, download access, and retention cleanup aligned. Deleting an archive must not leave a successful record that points to missing data.
- Keep webhook operation values aligned across event producers, registration data, queue validation, and worker filtering. Preserve the distinction between a missing bookmark and a deleted-bookmark event.
- Keep each administrative task type registered in the shared schema, the worker dispatch, and the admin enqueue path. A schema-only task becomes an accepted job with no handler.
- When a maintenance task changes asset or bookmark storage, preserve quota checks and the database-to-file relation as one complete state transition.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A rule references a tag or list outside the user's scope | The rule cannot be created or updated, so the intended automation is not installed | Validate every referenced tag and list before saving the rule. |
| A rule action changes a bookmark that no longer exists | The rule job has no current state to change and is skipped | Treat missing bookmarks as no-op jobs and rely on the source record's current existence. |
| An import item remains processing after a worker stops before creating a bookmark | The item can block session completion | Reset stale processing items that have no result bookmark, while leaving items that await crawl or tagging for downstream completion. |
| An import contains an asset bookmark | The item is rejected as unsupported and the session reports a failed result | Use link or text records for the supported import path. |
| A backup exceeds the user's storage quota or archive creation fails | The backup remains a failure and has no usable archive | Check quota before storing the asset and update the backup record on failure. |
| A webhook destination times out or returns a non-success response | That destination is not counted as delivered after its retry limit, while other destinations can still finish | Use the worker timeout and retry policy and make the receiver safe for repeated delivery. |
| A maintenance task has an invalid type or malformed arguments | The job fails instead of running an unknown operation | Validate the discriminated task payload before dispatch. |
| Large HTML is stored as an asset but the bookmark relation update fails | Temporary storage can exist without a usable bookmark relation | Check quota first and remove the new asset when the relation transaction fails. |
Key files
| File | Why to read it |
|---|---|
| apps/…/index.ts | Shows which automation and operations workers start and how their lifecycles differ. |
| packages/…/queues.ts | Defines the queue names and payload contracts for rules, backups, webhooks, and maintenance. |
| apps/…/ruleEngineWorker.ts and packages/…/ruleEngine.ts | Show how user events become rule matches and bookmark actions. |
| packages/…/rules.ts | Defines the user-facing event, condition, and action vocabulary. |
| apps/…/importWorker.ts | Shows session polling, fair batch claims, item outcomes, and downstream completion. |
| packages/…/importSessions.ts and packages/…/importSessions.service.ts | Define the import session controls and the state boundary used by clients. |
| apps/…/backupWorker.ts | Shows scheduled and manual archive creation, asset storage, failure state, and retention cleanup. |
| packages/…/backups.ts and packages/…/backups.ts | Define backup records and the user-facing trigger and status operations. |
| apps/…/webhookWorker.ts and packages/…/webhooks.service.ts | Show event selection, external delivery, timeout, and retry behavior. |
| apps/…/adminMaintenanceWorker.ts | Shows the maintenance task boundary and dispatch rules. |
| apps/…/tidyAssets.ts and apps/…/migrateLinkHtmlContent.ts | Show the two current data repair responsibilities and their storage safeguards. |
| packages/…/admin.ts | Shows how administrators start maintenance work and inspect queue pressure. |