---
title: Builtin Pipelines
description: Builtin pipelines provided by Cavaliba
weight: 30
---

Builtin pipelines are loaded at startup and are available to all schemas without any configuration.

All builtin pipelines carry a `run_permission` of `p_pipeline_run`. The caller must hold this permission to execute them against a schema.


## bulk_disable_out_of_sync

Disables assets whose `last_sync` field is older than 3 months.

This pipeline is intended to be applied to any Schema that tracks synchronization with an external system via a `last_sync` field. Assets that have not been seen for more than 3 months are marked for disable by setting `_action: disable`.

Assets without a `last_sync` field or with a recent sync date are **not modified** — they are discarded by the pipeline and left untouched in the database.

**Logic:**

| Step | Task | Effect |
|---|---|---|
| 1 | `field_set _action noop` | Safe default — no change unless stale |
| 2 | `field_datetime _cutoff now() -3month` | Compute cutoff = now − 3 months |
| 3 | `set_condition HAS_SYNC exists last_sync` | True if `last_sync` field is present |
| 4 | `set_condition IS_STALE lt last_sync _cutoff` | True if `last_sync` is older than cutoff |
| 5 | `discard !HAS_SYNC` | Skip assets with no `last_sync` (left untouched in DB) |
| 6 | `discard !IS_STALE` | Skip recently synced assets (left untouched in DB) |
| 7 | `field_set _action disable` | Mark stale assets for disable |
| 8 | `field_delete _cutoff` | Remove temporary field |

**Notes:**

- `last_sync` must be a datetime string in `YYYY-MM-DD HH:MM:SS` format.
- The 3-month threshold is computed at pipeline execution time from the current local datetime.
- Discarded entries are never written to the database — only stale assets are updated.


## bulk_delete_out_of_sync

Deletes assets that are **already disabled** and whose `last_sync` field is older than 6 months.

This pipeline is the second step of a two-phase cleanup workflow. It only targets assets that have previously been disabled (e.g. by `bulk_disable_out_of_sync`) and have still not been seen for 6 months. Assets that are still enabled, have no `last_sync` field, or were synced recently are not modified.

**Typical workflow:**

1. Apply `bulk_disable_out_of_sync` — disables assets not seen for 3 months
2. Apply `bulk_delete_out_of_sync` — deletes assets that remain disabled and unseen for 6 months

**Logic:**

| Step | Task | Effect |
|---|---|---|
| 1 | `field_set _action noop` | Safe default — no change unless criteria met |
| 2 | `field_datetime _cutoff now() -6month` | Compute cutoff = now − 6 months |
| 3 | `set_condition HAS_SYNC exists last_sync` | True if `last_sync` field is present |
| 4 | `set_condition IS_DISABLED is_false is_enabled` | True if asset is disabled |
| 5 | `set_condition IS_STALE lt last_sync _cutoff` | True if `last_sync` is older than cutoff |
| 6 | `discard !HAS_SYNC` | Skip assets with no `last_sync` (left untouched in DB) |
| 7 | `discard !IS_DISABLED` | Skip assets that are still enabled (left untouched in DB) |
| 8 | `discard !IS_STALE` | Skip recently synced assets (left untouched in DB) |
| 9 | `field_set _action delete` | Mark disabled+stale assets for deletion |
| 10 | `field_delete _cutoff` | Remove temporary field |

**Notes:**

- `last_sync` must be a datetime string in `YYYY-MM-DD HH:MM:SS` format.
- The 6-month threshold is computed at pipeline execution time from the current local datetime.
- Discarded entries are never written to the database — only disabled+stale assets are deleted.
- Assets that are still enabled are intentionally preserved, even if stale.


## bulk_delete_all

Deletes **all assets** of the target schema unconditionally.

> **Warning:** This pipeline is destructive and irreversible. All instances of the schema will be permanently deleted.

**Logic:**

| Step | Task | Effect |
|---|---|---|
| 1 | `field_set _action delete` | Mark every asset for deletion — no condition |

**Notes:**

- No conditions are checked — every instance in the schema is deleted.
- There is no undo. Back up your data before running this pipeline.
- A dry-run mode is available to preview the count without making changes.


## bulk_refresh

Re-saves all assets of the target schema without any modification. Triggers a read-then-write cycle for each instance, which refreshes the EAV cache and normalizes stored data.

Useful after schema changes, cache corruption, or bulk imports that bypassed normal save hooks.

**Logic:**

| Step | Task | Effect |
|---|---|---|
| 1 | `field_set _action update` | Re-save every asset — no condition, no data change |

**Notes:**

- No data is modified — assets are read and written back as-is.
- All instances are processed, regardless of their enabled/disabled status.
- This pipeline has no destructive effect.


## bulk_discard

Browse and skip all assets of the target schema. Use for tests or perf benchmark.

Useful after schema changes, cache corruption, or bulk imports that bypassed normal save hooks.


**Notes:**

- Data is not rewritten to DB ; no update of last_update fields.
- All instances are processed, regardless of their enabled/disabled status.
- This pipeline has no effect


