/** * src/measurement/write.ts * * Atomic writer + helpers for ATR benchmark measurement files. * * Used by every eval script. Guarantees: * - Schema-valid output (calls `parseMeasurement` before write). * - Atomic write (tmp file + fsync + rename — no half-written files). * - `latest.json` is updated only after the underlying file is durable on disk. * - Caller-supplied measurements receive `schema_version`, `measured_at`, * `atr_version`, `atr_commit`, and `rules_loaded` autofills if omitted. */ import { type Measurement } from "./schema.js"; /** Read the ATR version from `package.json`. */ export declare function readATRVersion(): string; /** Read the current short git SHA. Falls back to `"unknown"` outside a git repo. */ export declare function readATRCommit(): string; /** Best-effort: count `ATR-*.yaml` rule files under `rules/`. */ export declare function countRules(rulesDir?: string): number; /** * Caller-friendly subset of `Measurement`. The fields the eval script must * provide; the rest (`schema_version`, `atr_version`, `atr_commit`, * `rules_loaded`, `measured_at`) are autofilled by `writeMeasurement()`. * * Callers MAY override any autofill by setting the field explicitly. */ export type MeasurementInput = Omit & { measured_at?: string; atr_version?: string; atr_commit?: string; rules_loaded?: number; }; /** * Write a measurement file and update the source's `latest.json`. * * Returns the absolute path of the measurement file that was written. * * Behavior: * 1. Autofill `schema_version`, `measured_at` (now, ISO UTC), `atr_version`, * `atr_commit`, `rules_loaded` if not provided. * 2. Validate via `parseMeasurement()`. Throws on any schema violation. * 3. Compute the canonical filename. * 4. Refuse to overwrite an existing file unless `opts.force` is true. (We * maintain the append-only invariant by default.) * 5. Atomic write the measurement file. * 6. Update `latest.json` only if the new measurement is strictly newer. * * @param input Measurement minus the autofilled fields. * @param opts Options. `force: true` allows overwriting an existing file * with the same filename (use with caution; breaks append-only). */ export declare function writeMeasurement(input: MeasurementInput, opts?: { force?: boolean; rulesDir?: string; }): { measurementPath: string; latestPath: string; measurement: Measurement; }; /** Resolve the absolute path of a source's `latest.json`. */ export declare function latestPath(source: string): string; /** Absolute path of the measurements root directory. */ export declare function measurementsDir(): string; //# sourceMappingURL=write.d.ts.map