> ## 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.

# D

# D — shared-cost bases

## Goal

Split shared ClickHouse, Modal, Cloudflare, Vercel and storage by a measured basis,
leaving the residual explicit. Current work is owner/tenant splits, not run or
conversation bases. The scoreboard holds current values; policy lives in the
[architecture](../architecture.md).

## Metric

Share of shared-dollar exposure allocated by a measured basis. A measured row
must use the SQL executor's `allocation:` method, a versioned basis and a positive
basis quantity. Estimated allocations and named idle/internal residuals remain
in the denominator, not the measured numerator. E checks signed bill closure.

## 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
)
SELECT provider,sum(abs(toInt128(cost_nanos))) AS shared_exposure_nanos,
  sumIf(abs(toInt128(cost_nanos)),kind='allocated' AND startsWith(method,'allocation:')
    AND basis_metric!='' AND method_version!='' AND basis_quantity>0) AS measured_nanos,
  measured_nanos/nullIf(shared_exposure_nanos,0) AS measured_share,
  shared_exposure_nanos-measured_nanos AS explicit_residual_nanos,
  toUInt8(shared_exposure_nanos>0 AND measured_nanos=shared_exposure_nanos) AS exit_pass
FROM moda.cost_ledger_daily FINAL
PREWHERE day>=toDate(now('UTC'))-7 AND day<toDate(now('UTC'))
WHERE (day,ledger_run_id) IN (SELECT day,run FROM publications)
  AND (provider IN ('clickhouse_cloud','modal','cloudflare','vercel') OR positionCaseInsensitive(bill_sku,'storage')>0)
GROUP BY provider ORDER BY provider
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

From the [merged map](../pr-lane-map.md): #11519 (ClickHouse internal CPU buckets),
\#11374 (explicit Modal internal classification), #11310 (Modal tenant allocation),
\#11308 (occupancy/idle/untagged). Coordinate occupancy prerequisites in B2's
\#11309 without pushing to it. Park D's per-run/per-conversation bases until the
run/message rungs; adopt only owner/tenant slices now.
The collector's `clickhouse-basis.clickhouse-local.test.ts` belongs to E for
old-ledger retirement (#11642, after #11646's ownership correction lands).
The production ClickHouse basis implementation remains D-owned.

## Stop-and-ask conditions

Stop before a migration, deploy or flag flip; on estimated/fabricated bases,
unexplained residual redistribution, or a proposed run/conversation expansion.
Follow [standing rules](README.md).

## Exit check

Every expected shared provider must appear with `exit_pass=1` for complete
measured coverage; missing/empty providers fail. Otherwise report the query's
explicit residual, not an invented split. A deliberate idle/fixed residual needs
architect approval of its owner/class and does not become measured allocation.


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