/** * Age-based retention for the v-next Postgres observability domain. * * The signal tables are insert-only and day-partitioned (native declarative * partitions, pg_partman-managed partitions, or Timescale chunks), so * retention here is NOT the row-level batched `DELETE` used by the other * domains — it expires data the way the partition skeleton was designed for: * * - native / partman: `DETACH PARTITION` + `DROP TABLE` for every child * partition whose upper bound is at or before the cutoff. Detach-then-drop * keeps the parent lock window short, and dropping a whole day of events * is O(1) — no dead tuples, no WAL churn, no vacuum debt. * - timescale: `drop_chunks(older_than => cutoff)`, the Timescale-native * equivalent (only chunks wholly older than the cutoff are dropped). * * Because only *whole* partitions/chunks are dropped, the effective * granularity is one day: rows stay until the full day they belong to has * aged past `maxAge`. Empty future partitions (pre-created for routing) have * upper bounds in the future and are never touched. * * `PruneOptions` map onto partition drops: each dropped partition counts as * one batch (`maxBatches` caps partitions dropped per table per call), * `maxRows` stops before a drop that would exceed the row budget, and the * abort signal is checked between drops. `deleted` reports the number of * rows in the dropped partitions/chunks. */ import type { PruneOptions, TableRetentionPolicy } from '@mastra/core/storage'; import type { DbClient } from '../../../client.js'; export interface PartitionPruneOutcome { deleted: number; done: boolean; } /** Convert a policy's `maxAge` into a cutoff `Date`. */ export declare function retentionCutoff(policy: TableRetentionPolicy, now?: number): Date; /** * Drops every child partition of `table` whose upper bound is at or before * `cutoff` (i.e. every row in it is provably older than the cutoff). * Detaches first so the parent's ACCESS EXCLUSIVE window is a fast catalog * change, then drops the detached table. Used for both native and * pg_partman-managed partitions (partman children are ordinary declarative * partitions; partman's own retention does the same detach+drop). */ export declare function prunePartitionedTable({ client, schema, table, cutoff, options, }: { client: DbClient; schema: string; table: string; cutoff: Date; options?: PruneOptions; }): Promise; /** * Drops every Timescale chunk of `table` wholly older than `cutoff` via * `drop_chunks()`. Row counts are taken from the eligible chunks (reported by * `show_chunks()`) before the drop. The whole `drop_chunks()` call is a * single batch: it either runs or is skipped when `maxBatches` is 0 or the * signal is already aborted. */ export declare function pruneTimescaleTable({ client, schema, table, cutoff, options, }: { client: DbClient; schema: string; table: string; cutoff: Date; options?: PruneOptions; }): Promise; //# sourceMappingURL=retention.d.ts.map