> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moda.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# F

# F — reports and margins (parked)

## Goal

**Parked until the tenant rung passes.** Later expose marginal and fully loaded
cost per message from accepted publications, not a parallel ledger. The
scoreboard holds current values; see the [architecture](../architecture.md).

## Metric

Later: marginal serving cost per processed message, and fully loaded serving
cost per processed message including storage and the measured serving share of
Vercel/Cloudflare/fixed infrastructure, excluding R\&D/CI/retired work.
Today's query is only an output-readiness diagnostic: it counts messages in each
published snapshot and exposes marginal attributed cost. It deliberately does
not manufacture fully loaded margins before C/D establish serving classification
and fixed-cost splits. Message indexes here group an immutable publication's
messages; they are never used as historical coverage identities.

## Proof query

```sql theme={"dark"}
WITH publications AS (
  SELECT day,argMax(ledger_run_id,tuple(ledger_version,published_at,ledger_run_id)) AS run
  FROM moda.cost_ledger_publications
  WHERE day>=toDate(now('UTC'))-7 AND day<toDate(now('UTC')) GROUP BY day
), interactions AS (
  SELECT day,tenant_id,conversation_id,unit_id,
    argMax(tuple(message_index,cost_nanos),written_at) AS v
  FROM moda.cost_interaction_daily
  PREWHERE day>=toDate(now('UTC'))-7 AND day<toDate(now('UTC'))
  WHERE (day,ledger_run_id) IN (SELECT day,run FROM publications) AND kind!='internal'
  GROUP BY tenant_id,conversation_id,day,ledger_run_id,unit_id,stage,provider,kind,release
)
SELECT day,uniqExact(tuple(tenant_id,conversation_id,v.1)) AS messages,
  sum(toInt128(v.2)) AS marginal_attributed_nanos,
  marginal_attributed_nanos/nullIf(messages,0)/1000000000 AS marginal_attributed_usd_per_message,
  toUInt8(messages>0 AND countIf(tenant_id='' OR conversation_id='' OR unit_id='')=0) AS output_readiness_pass
FROM interactions
GROUP BY day ORDER BY day
SETTINGS readonly=2,max_threads=1,max_bytes_to_read=1000000000,max_result_rows=1000,
  max_execution_time=30,read_overflow_mode='throw',result_overflow_mode='throw'
```

## PRs to adopt now

None while parked. From the [merged map](../pr-lane-map.md), park #11516, #11521,
\#11528 and #11536 until the tenant rung passes and SQL publications are accepted;
fully loaded work also waits for measured serving bases. #11503's scoreboard
work is an existing prerequisite, not authorization to start detailed reports.
\#10907 is adjacent customer billing outside the provider-close cutover; parked
here until that work is separately authorized after the tenant rung.

## Stop-and-ask conditions

Stop before un-parking, changing a denominator, treating absent attribution as
zero, estimating unexplained cost into messages, or any deploy/migration.
Follow [standing rules](README.md).

## Exit check

The query's `output_readiness_pass` must pass for every expected day; missing
days/empty denominators fail. This is not permission to exit the parked state:
the architect must first confirm the tenant rung and C/D/E gates, then approve
a proof query for the fully loaded numerator. Neither a marginal output row nor
a successful diagnostic is proof that fully loaded margins are available.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.