New package
Reports are durable read models
smrt-reports turns repeated aggregate questions into materialized, tenant-aware s-m-r-t models that can rebuild, refresh incrementally, and run on a schedule.
Report model
Source rowsCompilerRefreshWatermarkSchedule
Declare the question beside the model
Report decorators describe dimensions, time buckets, and measures. The compiler produces a portable aggregate spec; the SDK query builder owns SQL generation.
DailySalesReport.ts
typescript
@report({ source: Sale, refresh: 'incremental' })
class DailySalesReport extends SmrtReport {
@timeBucket({ source: 'soldAt', unit: 'day' })
day = new Date();
@groupBy({ source: 'tenantId' })
tenantId = '';
@sum({ source: 'total' })
revenue = 0.0;
}Incremental refresh recomputes affected groups
A source watermark finds changed rows. s-m-r-t recomputes the groups those rows belong to and removes empty groups, avoiding the correctness traps of applying aggregate deltas blindly.
Operations are visible and recoverable
Runs, watermarks, locks, refresh tasks, and schedules are schema-managed system models. Cron and on-change refreshes use the existing jobs runtime rather than inventing a second queue.