# `vehicle@1`: odometer readings, fuel and charging, and maintenance

Version **1.0.0** · published 2026-12-02 · MIT · boards: vehicle-costs, vehicle-maintenance, small-fleet ·
[changelog](../CHANGELOG.md)

A vehicle's stable local key links cumulative distance observations, fuel and charging events, completed service, and
the next maintenance tasks. Vehicle Costs reads distances, quantities, and costs. Vehicle Maintenance reads service
history and due thresholds. Small Fleet compares cost, recorded use, and due tasks across vehicles.

Tracker's generic readings can hold an odometer value but cannot associate it with an energy purchase or service
invoice, and finance transactions cannot describe delivered quantity or a service cadence. The vehicle standard gives
those facts a shared key and keeps receipt totals at event grain.

## Conventions

- **Identity and privacy.** Use a source's stable, safe alias or a locally chosen alias for each vehicle. Namespace
  record ids by connector and account when a safe source id exists. Otherwise hash the stable natural key and a
  deterministic occurrence discriminator, independent of input ordering and import time. Do not store driver identity,
  VINs, plates, addresses, or payment identifiers in ids, labels, or provenance. Use local aliases for private source
  keys. Keep each payment account on one import source. When both a statement and a receipt describe the same purchase,
  select one source and report the other as an issue; never match by amount, date, or vehicle alone.
- **Distance and dates.** `day` is the event's local date (`YYYY-MM-DD`), not the import date. Distance and cadence
  use metres, with `1 mi = 1609.344 m`. Convert a reading to whole metres once at import. The odometer is cumulative,
  so use differences over intervals with observed endpoints. Do not treat unknown distance as zero. A fall between
  dates is reported as a quality warning. A documented meter replacement can be normalised through an override with
  evidence. Never derive mileage across an unexplained fall. Multiple observations on the same day are allowed and
  not ordered by id. Fleet analysis can use optional inclusive dates in service. A day with no reading gives no
  evidence that the vehicle was parked.
- **Energy.** Liquid volume is in litres (`1 US gal = 3.785411784 L`, `1 imperial gal = 4.54609 L`). Electricity
  is delivered energy in watt-hours (`energy_wh = kWh × 1000`, the unit chargers and utilities report, scaled to a
  base unit); divide by 1000 to display kWh. Never convert charging energy to kilocalories. Keep the
  two quantities separate. A statement-only cost can leave quantity and fill status unknown. Likewise a charge log
  can have quantity with no known cost. Use `energy_kind = unknown` when there is no reliable classification. Set
  `fill_complete` only on a measured liquid fill, and use an explicit full-to-full interval for liquid efficiency.
  Purchased electricity per distance is only an estimate when charging or distance coverage is incomplete.
- **Money.** Costs use major units, positive for expense and negative for refund or rebate. A refund on an energy
  purchase carries no delivered quantity. Original cost and currency are either both present or both absent. Set
  `cost_base` only when an actual conversion is known, with the same sign as the original. A cost already in the base
  currency can use its original amount directly. Do not total unknown conversions or report them as zero. Count the
  cost of a service invoice once per `service_id`, even if multiple tasks were completed on that visit.
- **Due service.** A recurring task derives a due threshold from its last documented completion: completion day plus
  `interval_days`, or its linked reading plus `interval_m`. A known explicit threshold takes precedence for its own
  dimension. A task with both thresholds is due when either is met. If no completion or explicit threshold is known,
  the due status remains unknown; a cost-only invoice with no mapped task cannot complete a task. Never infer an
  odometer value from the service date. Service records link a reading only when observed for the same vehicle and
  local date.
- **Provenance.** Every fact has a connector id, safe source reference, and UTC import instant. Use `confidence`
  when a value is inferred. Keep import instants out of `meta.data_hash` so re-importing identical facts preserves
  the hash. Use `data_issues` to account for rows skipped or requiring attention. Keep raw files and private identifiers
  out of annotations, issues, and sample exports.

## Sources that fill it

| Source | Lane | Fills |
|---|---|---|
| Odometer export or a locally maintained log | 1 | `vehicles`, `odometer_readings` |
| Fuel receipt, fuel-card CSV or bank CSV with vehicle assignment | 1 | `energy_purchases`; `odometer_readings` when a reading was observed |
| Charging-network export | 1 | `energy_purchases`; cost only when provided |
| Service records and local reminder settings | 1 | `service_records`, `service_tasks`, `service_items`; `odometer_readings` when supplied |

## Compatibility

- A board that declares `vehicle@1 >=1.0` keeps working on later 1.x databases.
- Remixes that add only metrics, pages and `x_<owner>_` tables survive every minor.
- Breaking changes go to `vehicle@2` with a migration and `metrics-codemod.py`. See [Semver](../../README.md#semver-what-is-breaking).

## Fields

<!-- fields:begin (generated from schema.sql by spec/build.py; edit the DDL comments) -->

### `meta` (required table)

Key/value facts about this database.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `key` | TEXT | **yes** | schema, schema_version, as_of, data_hash, source_built_at or base_currency |
| `value` | TEXT | no | text; dates as YYYY-MM-DD |

### `vehicles` (required table)

One vehicle, identified by a local or source-assigned alias.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `vehicle_id` | TEXT | **yes** | stable vehicle id; never a VIN, plate, driver or payment identifier |
| `label` | TEXT | **yes** | display alias such as Birch Van; omit identifiers and names |
| `powertrain` | TEXT (vocab `powertrains`) | no | controlled vehicle powertrain, NULL when unknown |
| `active_from` | TEXT (date) | no | first day in service for the fleet, if known |
| `active_to` | TEXT (date) | no | last day in service, inclusive; NULL when open or unknown |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `odometer_readings` (required table)

One observed cumulative distance reading from a log, receipt, or service record.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `reading_id` | TEXT | **yes** | stable reading id |
| `vehicle_id` | TEXT | **yes** | vehicle observed |
| `day` | TEXT (date) | **yes** | local calendar date of the reading |
| `odometer_m` | INTEGER | **yes** | cumulative distance in whole metres; zero is valid |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `energy_purchases` (required table)

One fuel purchase, charging session, or related refund; source data may contain only cost or only quantity.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `purchase_id` | TEXT | **yes** | stable purchase, session, or refund id |
| `vehicle_id` | TEXT | **yes** | vehicle that incurred the cost or took the energy |
| `day` | TEXT (date) | **yes** | local transaction or session date |
| `energy_kind` | TEXT (vocab `energy_kinds`) | **yes** | fuel, electricity or unknown energy classification |
| `volume_l` | REAL | no | litres delivered for liquid fuel |
| `energy_wh` | REAL | no | electrical energy delivered, in watt-hours (1 kWh = 1000 Wh; display kWh = energy_wh / 1000) |
| `fill_complete` | INTEGER | no | 1 full tank, 0 partial fill, NULL unknown or not liquid fuel |
| `reading_id` | TEXT | no | optional odometer observed at this event |
| `cost_amount` | REAL | no | positive expense or negative refund, original currency major units |
| `currency` | TEXT (currency) | no | ISO 4217 code when cost_amount is present |
| `cost_base` | REAL | no | signed amount converted to meta.base_currency only when known |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `service_records` (required table)

One completed workshop visit or service event. Financial totals belong on this row even if several tasks were done.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `service_id` | TEXT | **yes** | stable event or invoice id |
| `vehicle_id` | TEXT | **yes** | serviced vehicle |
| `day` | TEXT (date) | **yes** | local date the service was completed |
| `reading_id` | TEXT | no | optional odometer observed at this event |
| `description` | TEXT | no | safe short service description, with private identifiers removed |
| `cost_amount` | REAL | no | net cost in original currency major units |
| `currency` | TEXT (currency) | no | ISO 4217 code when cost_amount is present |
| `cost_base` | REAL | no | signed amount converted to meta.base_currency only when known |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `service_tasks` (required table)

One tracked service task for a vehicle, with an optional recurring cadence or a known next-due threshold.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `task_id` | TEXT | **yes** | stable task id; two distinct tasks may share a kind |
| `vehicle_id` | TEXT | **yes** | vehicle the task applies to |
| `label` | TEXT | **yes** | display alias such as Front tyres |
| `service_kind` | TEXT (vocab `service_kinds`) | **yes** | controlled maintenance category |
| `interval_days` | INTEGER | no | elapsed calendar days between services, when known |
| `interval_m` | INTEGER | no | elapsed metres between services, when known |
| `due_on` | TEXT (date) | no | explicit next-due date from source or override |
| `due_odometer_m` | INTEGER | no | explicit next-due cumulative metres from source or override |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `service_items` (required table)

One completed service task in a service record. No monetary totals on this link.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `service_id` | TEXT | **yes** | record that completed the task |
| `task_id` | TEXT | **yes** | task completed on the same vehicle |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | export row or safe source id |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `confidence` | TEXT (vocab `confidence`) | no | attribution for inferred values |

### `data_issues`

Import issues keep source rows visible even when no vehicle fact can be safely emitted.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `issue_id` | TEXT | **yes** | stable issue id |
| `severity` | TEXT (vocab `severities`) | **yes** | info, warn or error |
| `kind` | TEXT | **yes** | machine-readable reason such as unknown_vehicle or invalid_units |
| `title` | TEXT | **yes** | short display title |
| `detail` | TEXT | **yes** | plain explanation without private source text |
| `source` | TEXT | **yes** | connector id |
| `source_ref` | TEXT | **yes** | safe source id or file and line |
| `imported_at` | TEXT (instant) | **yes** | UTC import instant |
| `handling` | TEXT | **yes** | what the importer did |

### `overrides`

Local corrections applied during import.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `override_id` | TEXT | **yes** | stable override id |
| `target` | TEXT | **yes** | table.key.column the override applies to |
| `field` | TEXT | no | column name |
| `old_value` | TEXT | no | value before |
| `new_value` | TEXT | no | value after |
| `reason` | TEXT | **yes** | why, in the person's words |
| `evidence` | TEXT | no | where it comes from |
| `author` | TEXT | no | person or assistant |
| `created_at` | TEXT (instant) | no | UTC instant |

### `annotations`

Notes on metrics and pages. Numbers only through {{metric:...}} placeholders.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `annotation_id` | TEXT | **yes** | stable note id |
| `target` | TEXT | **yes** | metric id or page id |
| `kind` | TEXT | **yes** | note, caveat, flag, decision or open_item |
| `body` | TEXT | **yes** | note text |
| `author` | TEXT | no | person or assistant |
| `source_ref` | TEXT | no | where it came from |
| `created_at` | TEXT (instant) | no | UTC instant |
| `data_hash` | TEXT | no | hash of the cited metric values when written |
| `status` | TEXT | no | active, stale or retired |

### `metric_registry`

The board's metrics, installed from metrics.sql by the importer.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `metric_id` | TEXT | **yes** | metric id |
| `version` | INTEGER | no | metric's own version |
| `unit` | TEXT | no | unit of output |
| `params` | TEXT | no | comma-separated parameters |
| `description` | TEXT | no | the @desc line |
| `sql` | TEXT | no | expanded SQL |
| `test` | TEXT | no | the @test line |

<!-- fields:end -->

## Vocabularies

`powertrains.csv` groups fleet vehicles. `energy_kinds.csv` distinguishes electricity, liquid fuel, and unclassified
receipts. `service_kinds.csv` groups service tasks without making the category their identity. `confidence.csv` records
how a value was attributed, and `severities.csv` describes import issues.

## Conformance checks

See `checks.yaml`. `dashremix spec check <db> vehicle@1` runs it after checking the DDL, meta keys and row schemas.
The checked-in fixtures show two fictional vehicles, a cost-only receipt, quantity-only charging, a fuel refund,
a multi-task service invoice, mileage- and date-based service rules, and one quarantined row.
