/** * GovernanceObserver — Observability Bridge for Governance Operations * * Wraps governance operations (contract compilation, lockfile generation, * integrity verification, attestation) with structured debug events and * OpenTelemetry-compatible tracing spans. * * This module is the bridge between the governance/introspection layer * and the observability layer. It is opt-in — governance operations * work identically without it. When enabled, every governance operation * emits a `GovernanceEvent` and/or a tracing span. * * **Zero overhead when disabled**: When no observer or tracer is * configured, the wrapper functions are no-ops that delegate directly. * * @module */ import type { DebugObserverFn, GovernanceOperation } from '../observability/DebugObserver.js'; import type { FusionTracer } from '../observability/Tracing.js'; /** * Configuration for governance observability. * * Pass to `createGovernanceObserver()` to enable debug events * and/or tracing spans for governance operations. */ export interface GovernanceObserverConfig { /** Debug event handler — receives GovernanceEvent */ readonly debug?: DebugObserverFn; /** OpenTelemetry-compatible tracer */ readonly tracer?: FusionTracer; } /** * A governance observer that emits debug events and tracing spans. * * All methods accept a callback that performs the actual work. * The observer wraps the callback with timing and event emission. */ export interface GovernanceObserver { /** * Wrap a governance operation with observability. * * @param operation - Named governance operation * @param label - Human-readable label * @param fn - The actual work to perform * @returns The result of `fn` */ observe(operation: GovernanceOperation, label: string, fn: () => T): T; /** * Wrap an async governance operation with observability. * * @param operation - Named governance operation * @param label - Human-readable label * @param fn - The actual async work to perform * @returns The result of `fn` */ observeAsync(operation: GovernanceOperation, label: string, fn: () => Promise): Promise; } /** * Create a governance observer that emits debug events and/or tracing * spans for governance operations. * * @param config - Observer configuration (debug handler and/or tracer) * @returns A `GovernanceObserver` instance * * @example * ```typescript * import { createGovernanceObserver } from '@vinkius-core/mcp-fusion/introspection'; * import { createDebugObserver } from '@vinkius-core/mcp-fusion'; * * const observer = createGovernanceObserver({ * debug: createDebugObserver(), * }); * * const contracts = observer.observe( * 'contract.compile', * 'Compiling 5 tool contracts', * () => compileContracts(builders), * ); * ``` */ export declare function createGovernanceObserver(config: GovernanceObserverConfig): GovernanceObserver; /** * Create a no-op governance observer. * * Used when observability is not configured. Zero overhead. */ export declare function createNoopObserver(): GovernanceObserver; //# sourceMappingURL=GovernanceObserver.d.ts.map