export type WriteEventReason = "invalid-input" | "schema-unknown-label" | "schema-property-naming" | "account-isolation" | "producedby-task-not-found" | "constraint-violation" | "conflicting-element-id" | "invalid-target-node-id" | "gate-blocked" | "neo4j-driver-error";
interface SuccessEvent {
    tool: string;
    result: "ok";
    accountId?: string;
    session?: string;
    labels?: readonly string[];
    name?: string;
    elementId?: string;
    durationMs: number;
}
interface ErrorEvent {
    tool: string;
    result: "error";
    reason: WriteEventReason;
    detail: string;
    accountId?: string;
    session?: string;
    labels?: readonly string[];
    name?: string;
    durationMs: number;
}
export type WriteEvent = SuccessEvent | ErrorEvent;
/** Format the structured line that will be sent over the wire. */
export declare function formatWriteEventLine(ev: WriteEvent): string;
/** POST the formatted line to the loopback ingest route. Falls back to stderr. */
export declare function emitWriteEvent(ev: WriteEvent): Promise<void>;
export interface WithWriteEventBase {
    tool: string;
    accountId?: string;
    /** Optional pre-known labels (memory-write supplies these from params). */
    labels?: readonly string[];
    /** Optional pre-known name (rarely set up front; usually extracted from result). */
    name?: string;
    /** Override the env-derived session id when one is more authoritative. */
    session?: string;
}
export interface WithWriteEventExtract {
    labels?: readonly string[];
    name?: string;
    elementId?: string;
}
/**
 * Wrap a tool body so a structured event is emitted exactly once on every
 * exit path. The wrapper measures durationMs, classifies thrown errors via
 * `classifyReason`, and lets caller-supplied `extract` enrich the success
 * line with labels / name / elementId that are only known after the write.
 */
export declare function withWriteEvent<T>(base: WithWriteEventBase, body: () => Promise<T>, extract?: (result: T) => WithWriteEventExtract): Promise<T>;
/**
 * Map a thrown value to one of the enumerated WriteEventReason slugs.
 * The match shapes are derived from the actual `throw new Error(...)`
 * messages in the write-path tools as of 2026-05-19 (see Task 166 §In scope 2).
 * Anything unmatched lands on `neo4j-driver-error`; never silently
 * fall through to a synthesized "unknown" slug.
 */
export declare function classifyReason(err: unknown): WriteEventReason;
/**
 * Pick a human-readable name for the structured log line out of a properties
 * bag. Follows the task-spec preference: `name → title → email`, returning
 * undefined when none are present so the line renders `name=—`.
 */
export declare function pickName(properties: Record<string, unknown> | undefined): string | undefined;
export {};
//# sourceMappingURL=log-ingest.d.ts.map