Continuous RAG Evaluation and Faithfulness Gate with Ragas
Continuously evaluate RAG pipeline accuracy with Ragas, measuring faithfulness and context precision with Slack alerting on quality degradation.
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 Query with searchType: FETCH_OBJECTS and a LIKE filter on retention_property, and counts the matching objects through its size output. fetchType: STORE writes the matched rows, holding only retention_property, to Kestra storage instead of the execution context. Plugin-weaviate 2.0+ has no aggregation, so the count is capped at scan_limit (default 10000, which must not exceed the server's QUERY_MAXIMUM_RESULTS); a larger backlog reads as scan_limit and is still cleared by the loop below.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; weaviate.Delete repeats it until no match is left, so one pass of the loop usually clears the backlog. The re-count after each delete is what makes a partial clear, for example objects written during the purge, 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. The flow was then migrated to the structured Query of plugin-weaviate 2.0 and re-run on Weaviate 1.39 with QUERY_MAXIMUM_RESULTS=3 and scan_limit=3: the dry run reported 3 (the capped count) and deleted nothing, the remediate path's Delete removed all 7 stale objects in one pass, left the 5 current objects in place and re-verified 0 remaining, and the next run took the clean path.
A reachable Weaviate 1.32+ cluster, reachable over REST and gRPC (port 50051 by default; set grpcHost and grpcPort to override), 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.scan_limit: the most stale objects counted per query, at most the server's QUERY_MAXIMUM_RESULTS.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.