Current Flow
- Durable Object buffer (SQLite) stores fresh usage and verification records.
- Flush pipeline sends the same batch to Tinybird and R2 raw NDJSON.
- Deletion safety only removes buffered rows after both Tinybird and R2 cursors advance.
- Compaction merges raw R2 files per day into compacted files for lakehouse queries.
Compatibility Contract
- Every event includes
schema_version. - Prefer additive changes (new nullable fields) over breaking changes.
- Keep old fields during migration windows so dashboards and SQL consumers do not break.
- Treat schema changes as a multi-sink rollout, not a single table change.
Safe Change Types
- Add nullable field
- Add optional enum value
- Add derived field while keeping original field
Breaking Change Types
- Removing fields used by dashboards
- Renaming fields without compatibility alias
- Changing semantic type (example: numeric to string)
- Changing partition/path conventions without reader fallback
schema_version, deploy readers first, writers second.
Rollout Order
- Readers first
- Update dashboards and SQL rooms queries to support old + new schema.
- Update compaction/manifest readers to tolerate both shapes.
- Writers second
- Update DO/Tinybird/R2 payload writers.
- Keep old fields if possible during transition.
- Validation window
- Monitor ingestion, query errors, and compaction output.
- Cleanup
- Remove legacy fields only after all consumers are migrated.
Security and Integrity in Tiered Flush
- Atomic intent: flush is best-effort per destination, but row deletion only happens after both Tinybird and R2 succeed for the processed range.
- Idempotency: usage id + cursor checks prevent double counting on retries.
- Metadata stability: metadata is deduplicated and tied by
meta_id, so usage/verification can still be joined after compaction. - Access control: realtime API endpoints remain key-authenticated; dashboard websocket connections are session-token validated.
Impact on SQL Rooms Dashboards
SQL rooms queries should be version-aware during migrations. Recommended pattern:Impact on Compaction
- Compaction is file-level and idempotent.
- Compaction does not transform schema; it merges raw NDJSON lines.
- If schema changes mid-day, compacted output can contain mixed
schema_versionvalues for that partition day.
Operational Checklist
- Add/update
schema_versionwhere payload shape changed. - Verify Tinybird ingest schemas accept new fields.
- Verify R2 manifest + readers still resolve old and new file layouts.
- Verify SQL rooms queries run for both versions.
- Run manual compaction for target day and validate output.
- Monitor realtime endpoint and websocket dashboards during rollout.

