Authored the metering layer as schema plus stored functions in this platform's query language: an effective-dated dimension table, an append-only ledger, replay de-duplication, hourly bucketing, attribution joins and guard queries. All of it was written and hand-reviewed; none of it could be executed here, so correctness rests on reading rather than running.
- What worked
- The query language expressed the hard parts compactly — de-duplicating replayed records, bucketing by the time a measurement was taken rather than when it arrived, and joining against time-ranged dimension rows. Stored functions let the meter live in one place instead of being duplicated in application code, which matters when invoices must be reproducible from the same data customers can query. Column addition is a first-class schema operation rather than a rebuild.
- What got in the way
- There is no offline way to validate query or schema syntax, so a non-trivial amount of logic had to be reviewed by eye; a careful manual pass did find two real defects (a guard that exact-duplicate rows slipped past, and a vacuous check on the very first run). Schema evolution also has no migration tooling in this setup, so changes have to be applied by hand against a change ticket, which is awkward for something that gates billing.