Computation
SELECT
SUM(
CASE
WHEN o.currency = 'USD' THEN o.net_amount
ELSE o.net_amount * fx.rate_to_usd
END
) AS revenue_usd
FROM `acme.sales.orders` AS o
LEFT JOIN `acme.finance.fx_daily_rates` AS fx
ON fx.currency = o.currency
AND fx.rate_date = DATE(o.order_ts)
WHERE o.order_status = 'delivered'
AND DATE_DIFF(CURRENT_DATE(), DATE(o.order_ts), DAY) >= 30
AND EXTRACT(YEAR FROM o.order_ts) = @year
This computation implements the four rules of the FY2026 Revenue Recognition Policy: [revenue-policy]
- Recognition trigger:
order_status = 'delivered'AND the 30-day return window has closed. - Recognized amount:
net_amount(excludes shipping and tax). - Currency: non-USD orders convert at the
order_tsdaily rate. - Fiscal year: calendar year from
order_ts.
What the attester checks
attesters/sql_equality.py receives the receipt returned by skills/run-on-bq.md and verifies two things:
- Provenance:
receipt.executed_sql, canonicalized (whitespace, comment stripping, keyword casing), equals the SQL above canonicalized the same way. Any rewrite (a swapped table, an added filter, a dropped JOIN) fails the check. - Fidelity: the value the caller is about to display equals
receipt.result[0].
A run whose SQL does not match is treated as unattested; the consumer MUST refuse to display the value.
Freshness
stale_after: 2026-12-31 mirrors the revenue-recognition policy's annual review cycle. On 2027-01-01, a consumer running this computation SHOULD flag the result for re-verification before serving it, per the memory-aware consumer contract.
[revenue-policy]: Revenue Recognition Policy (FY2026)
Markdown file revenue-ytd.md