costs

Spend per step/record

What you'll learn

You're writing SQL that reads costs and need its columns, what each holds, and the DDL as the spec states it.

  • every column and its type
  • what the object holds and who writes it
  • the DDL as the spec states it

A table. Spend per step/record; basis measured|estimated (ADR-046: measured only when read back from vendor-reported cost metadata; a rate multiplied out is estimated)

Columns

ColumnTypeConstraints
idTEXTPRIMARY KEY
run_idTEXTNOT NULL
step_idTEXTNOT NULL
identity_idTEXT
providerTEXTNOT NULL
amount_usdREALNOT NULL
basisTEXTNOT NULL DEFAULT 'estimated'
detailTEXT
created_atTEXTNOT NULL

Definition

From spec/ledger.sql, which is the machine-checkable form of SPEC.md §3:

CREATE TABLE costs (
  id          TEXT PRIMARY KEY,
  run_id      TEXT NOT NULL,
  step_id     TEXT NOT NULL,
  identity_id TEXT,
  provider    TEXT NOT NULL,
  amount_usd  REAL NOT NULL,              -- 0 allowed (unknown/free)
  basis       TEXT NOT NULL DEFAULT 'estimated', -- measured|estimated (ADR-046)
  detail      TEXT,                       -- JSON (credits, tokens, etc.)
  created_at  TEXT NOT NULL
);

Used in

  • Report: One row per identity per step that spent, with amount_usd and basis