1#!/usr/bin/env node2'use strict';34// Derive MEASURED api_ms / api_calls / api_retries from a generated import's audit log, and emit5// them as a `meter` call. This exists so the API half of the latency split is populated6// mechanically rather than depending on anyone remembering to report it.7//8// node scripts/meter-from-audit.js --project <migration dir> [--stage import] [--dry-run]9//10// TRAP this deliberately handles: a bulk write logs ONE audit row PER ITEM, each carrying the11// BATCH's total latency. Summing `latencyMs` across rows therefore multiplies one call's latency by12// its item count — on a real run that turned 346s of elapsed import into 1,050,992ms of "API time",13// three times longer than the stage existed. Rows are collapsed per distinct14