/** * Verification evidence-atom extensions. * * This module extends the base evidence-atom vocabulary (defined in * `@cleocode/contracts`) with additional atom kinds: * * ### `metrics-delta` (Tier-3 auto-merge experiments — T1023) * * Proves that a Tier-3 auto-merge experiment produced measurable metric * improvements relative to a signed baseline. * * Format: `metrics-delta::` * * Both receipt IDs must correspond to `kind:"baseline"` events in the * project's sentient event log (`.cleo/audit/sentient-events.jsonl`). * * ### `loc-drop` (engine-migration tasks — T1604) * * Proves that a migrated engine shed ≥ a configured percentage of lines. * Required for the `implemented` gate whenever the task carries the * `engine-migration` label. * * Format: `loc-drop::` (both non-negative integers) * * ### `callsite-coverage` (production-callsite gate — T1605) * * Proves that an exported symbol has ≥1 production callsite outside its own * source file, test files, and dist directories. Required for the * `implemented` gate whenever the task carries the `callsite-coverage` label. * Catches the T1601 pattern where a function is shipped but never wired to * any production callsite. * * Format: `callsite-coverage::` * * @see packages/core/src/verification/gates.ts — `metricsImproved` gate * @task T1023 * @task T1604 * @task T1605 */ /** * A parsed `metrics-delta` evidence atom before validation. */ export interface ParsedMetricsDeltaAtom { /** Discriminant — always `'metrics-delta'`. */ kind: 'metrics-delta'; /** Receipt ID of the "before" baseline event. */ beforeReceiptId: string; /** Receipt ID of the "after" baseline event. */ afterReceiptId: string; } /** * A validated `metrics-delta` evidence atom, populated with the resolved * metrics from both baseline events. */ export interface ValidatedMetricsDeltaAtom { /** Discriminant — always `'metrics-delta'`. */ kind: 'metrics-delta'; /** Receipt ID of the "before" baseline event. */ beforeReceiptId: string; /** Receipt ID of the "after" baseline event. */ afterReceiptId: string; /** Parsed metrics from the before baseline. */ beforeMetrics: Record; /** Parsed metrics from the after baseline. */ afterMetrics: Record; /** ISO-8601 timestamp of the before baseline event. */ beforeTimestamp: string; /** ISO-8601 timestamp of the after baseline event. */ afterTimestamp: string; } /** * Result of validating a `metrics-delta` atom. */ export type MetricsDeltaValidation = { ok: true; atom: ValidatedMetricsDeltaAtom; } | { ok: false; reason: string; codeName: string; }; /** * Determine whether an `after` value represents an improvement over `before` * for a given metric key. * * @param key - Metric name. * @param before - Baseline value. * @param after - Experiment value. * @returns `true` when after is equal to or better than before. */ export declare function isMetricImproved(key: string, before: number, after: number): boolean; /** * Parse a raw `metrics-delta` atom string into its components. * * The format is: `metrics-delta::` * * @param payload - Everything after the `metrics-delta:` prefix. * @returns Parsed atom or an error result. * * @example * ```ts * parseMetricsDeltaAtom('ABCdef12345678901234X:XYZghi12345678901234A'); * ``` */ export declare function parseMetricsDeltaAtom(payload: string): { ok: true; atom: ParsedMetricsDeltaAtom; } | { ok: false; reason: string; }; /** * Validate a `metrics-delta` atom against the sentient event log. * * Steps: * 1. Load both `baseline` events by their `receiptId` from the event log. * 2. Verify the Ed25519 signature on both events. * 3. Check that the after event's timestamp is strictly later than the before * event's timestamp (anti-gaming: prevents passing a "future" baseline as * the before event and a "past" baseline as the after event). * 4. Parse `payload.metricsJson` from both events into numeric records. * 5. For every numeric key that appears in the after metrics, check the * improvement direction using {@link isMetricImproved}. * 6. Return a `ValidatedMetricsDeltaAtom` on success, or an error with * `E_EVIDENCE_TAMPERED` / `E_EVIDENCE_INSUFFICIENT` on failure. * * @param parsed - Parsed metrics-delta atom (from {@link parseMetricsDeltaAtom}). * @param projectRoot - Absolute path to the CLEO project root. * @returns Validation result. * * @task T1023 */ export declare function validateMetricsDeltaAtom(parsed: ParsedMetricsDeltaAtom, projectRoot: string): Promise; /** * The canonical label that triggers LOC-drop gate enforcement. * * When a task carries this label the `implemented` gate MUST be accompanied * by a `loc-drop` evidence atom proving the migrated engine shed lines. * * @task T1604 */ export declare const ENGINE_MIGRATION_LABEL = "engine-migration"; /** * Determine whether a task's labels include `engine-migration`. * * Accepts a `string[]` (from `task.labels`) or `null`/`undefined` for tasks * without labels. Returns `false` for any non-array value so callers can * pass the raw DB field without pre-checking. * * @param labels - Task labels array (from `task.labels`). * @returns `true` when the `engine-migration` label is present. * * @example * ```ts * hasEngineMigrationLabel(['foundation', 'engine-migration']); // true * hasEngineMigrationLabel(['foundation']); // false * hasEngineMigrationLabel(null); // false * ``` * * @task T1604 */ export declare function hasEngineMigrationLabel(labels: string[] | null | undefined): boolean; /** * The canonical label that triggers callsite-coverage gate enforcement. * * When a task carries this label the `implemented` gate MUST be accompanied * by a `callsite-coverage` evidence atom proving the exported symbol is * referenced from at least one production callsite outside its definition * file, test files, and dist directories. * * @task T1605 */ export declare const CALLSITE_COVERAGE_GATE_LABEL = "callsite-coverage"; /** * Determine whether a task's labels include `callsite-coverage`. * * Accepts a `string[]` (from `task.labels`) or `null`/`undefined` for tasks * without labels. Returns `false` for any non-array value so callers can * pass the raw DB field without pre-checking. * * @param labels - Task labels array (from `task.labels`). * @returns `true` when the `callsite-coverage` label is present. * * @example * ```ts * hasCallsiteCoverageLabel(['foundation', 'callsite-coverage']); // true * hasCallsiteCoverageLabel(['foundation']); // false * hasCallsiteCoverageLabel(null); // false * ``` * * @task T1605 */ export declare function hasCallsiteCoverageLabel(labels: string[] | null | undefined): boolean; //# sourceMappingURL=evidence-atoms.d.ts.map