Batch Ticket Classification with a Local Ollama Model
A shell loop inside one OllamaCLI task classifies every line of an input file with a local model, producing a CSV artifact and a Slack count report.
Count, delete and re-verify stale Weaviate objects by a retention key with Kestra behind dry-run and auto-remediate gates.
This blueprint keeps a Weaviate class free of stale vectors. In a retrieval store the vectors from a retired or re-ingested source keep matching queries they should no longer answer, which bloats the index and drags retrieval quality down. The flow counts the objects whose retention key matches a target value, deletes them behind a safety gate, then re-queries the store and fails if any stale object is left.
This blueprint was created by zkasuran.
The flow is read-only by default. It deletes only when auto_remediate is true and dry_run is false. In every other mode it reports the candidate count and the exact filter and changes nothing. After a delete it re-counts the stale objects and fails the run while any remain, so a partial clear never passes as success. The schedule ships disabled and pins both gates to safe mode.
detect runs a Weaviate GraphQL Aggregate query that counts objects whose retention_property matches retention_value.log_detect records the count, the filter and the current mode.guard acts only when the count is above zero. It posts a findings alert to Slack so the detection is visible even on a dry run.auto_remediate is true and dry_run is false, evict_until_clear runs. It is a LoopUntil that batch-deletes the matching objects through weaviate.Delete, re-counts them, then repeats until the count reaches zero or reverify_timeout elapses. failOnMaxReached fails the run if the backlog is not cleared in time.log_report_only records what would be deleted and the store is untouched.log_clean records that there is nothing to evict.errors block, which posts a Slack alert.A Weaviate batch delete removes at most QUERY_MAXIMUM_RESULTS objects per call, so a large backlog is cleared over several passes of the loop rather than in one call. The re-count after each delete is what makes a partial clear fail instead of reporting success.
Weaviate has no retention job and no scheduler. Left alone a class only grows and old vectors keep surfacing in results. Kestra adds the schedule, the dry-run and remediate gates, the Slack alerts and the execution history. The re-query after the delete is a first-class task, so the run proves the store is clean instead of assuming it.
Run on Kestra 2.0.5 against a self-hosted Weaviate 1.39 instance with anonymous access. A Document class was seeded with 5 current objects and 7 stale objects tagged source=deprecated. The clean path reported 0 and skipped eviction. The detect path found 7. The dry-run path reported 7 and left the count at 7. With the server batch-delete cap set to 3 per call, the remediate path cleared the 7 stale objects over three loop passes (7 to 4 to 1 to 0), left the 5 current objects in place and re-verified 0 remaining. A run pointed at an unreachable endpoint failed and fired the Slack errors block. Every count was confirmed with a direct GraphQL Aggregate call against Weaviate, not only from the Kestra log.
A reachable Weaviate cluster and a class whose objects carry a text property you can use as a retention key, for example source, tenant, batchId or docId.
SLACK_WEBHOOK_URL: incoming webhook for the findings and failure alerts.WEAVIATE_API_KEY: bearer key for a hosted cluster. Read on every Weaviate task unless anonymous is true.weaviate_url: the cluster endpoint, scheme and host with port.anonymous: set true for a cluster with anonymous access, which skips the API key.class_name: the class to scan.retention_property: the text property that tags each object with its origin or retention key.retention_value: the value that marks an object stale.reverify_timeout: the time budget for the eviction and re-verify loop.dry_run: report without deleting. Defaults to true.auto_remediate: allow deletion. Defaults to false.SLACK_WEBHOOK_URL as a Kestra secret. Store WEAVIATE_API_KEY too or set the anonymous input to true for a cluster with open access.weaviate_url, class_name, retention_property and retention_value to match your store and run with the other defaults. It reports the stale count and deletes nothing.auto_remediate to true and dry_run to false to evict and re-verify.daily_scan trigger to run the safe-mode scan every day.retention_property at tenant or docId to run an erasure by subject rather than by source.reverify_timeout on a small class or raise it when a very large backlog needs several passes.Pause before evict_until_clear to require human approval in production.Loop over a list of class names.