import type { DecisionAdapterBatchObservation, DecisionAdmissionEvidence, DecisionAttempt, DecisionEvaluationRequest, DecisionResult, ExecutionTarget, RulesetResult } from '../types.js'; import type { DecisionBatchReceipt } from '../batch-receipts/types.js'; import type { DecisionTelemetryLink, DecisionTelemetrySpan, TelemetryAttributes } from './types.js'; /** One open `decision.admit` span; closed exactly once. */ export interface DecisionAdmissionSpan { readonly span: DecisionTelemetrySpan; closed: boolean; } /** Metadata-only outcome of one D10 projection step; never the projected state or its digest. */ export interface DecisionProjectionSpanOutcome { mode: 'policy' | 'unprojected-local' | 'none'; outcome: 'allowed' | 'denied'; reason?: 'invalid-policy' | 'data-boundary-denied' | 'invalid-input'; fieldCount?: number; incompleteContext?: boolean; automaticActionAllowed?: boolean; } /** One live span plus the only context an adapter may forward to its transport. */ export interface DecisionRuntimeSpan { readonly span: DecisionTelemetrySpan; readonly traceContext: { traceparent: string; }; readonly ordinal: number; response?: DecisionAdapterBatchObservation; } /** * Records metadata-only spans while one evaluator invocation runs. Spans carry * live start/end times, are buffered in start order and flushed once after the * terminal result. Every failure disables the trace; none reaches the decision. */ export declare class DecisionRuntimeTrace { private readonly telemetry; private readonly now; private readonly builder; private readonly root; private validate?; private readonly batchSpans; private disabled; private constructor(); /** Start the root span and bind the trace to a request copy. Invalid ID sources disable telemetry. */ static begin(request: DecisionEvaluationRequest): { request: DecisionEvaluationRequest; trace: DecisionRuntimeTrace | null; }; /** W3C traceparent of the workflow span, for durable receipts created by this invocation. */ get traceParent(): string | undefined; validated(rejected: boolean): void; startAttempt(alias: string, target: ExecutionTarget, ordinal: number, fallback?: boolean): DecisionRuntimeSpan | undefined; endAttempt(handle: DecisionRuntimeSpan | undefined, attempt: DecisionAttempt): void; /** * Open the live D05 `decision.admit` span for one admission decision. A granted * lease stays open until release, so breaker transitions caused by the attempt * land inside the span; a rejection or deferral closes it at once. Evidence is * metadata-only by contract: principal and workspace IDs never reach the span. */ startAdmission(alias: string, adapterId: string, startedAtMs: number, evidence: DecisionAdmissionEvidence): DecisionAdmissionSpan | undefined; /** Close an admission span once; later calls are ignored. */ endAdmission(handle: DecisionAdmissionSpan | undefined, evidence: DecisionAdmissionEvidence): void; /** Record one D10 projection step, under its attempt span when there is one. */ projected(alias: string, parent: DecisionRuntimeSpan | undefined, startedAtMs: number, result: DecisionProjectionSpanOutcome): void; retryScheduled(handle: DecisionRuntimeSpan | undefined, delayMs: number): void; /** Open the shared request span before dispatch; its context is what the transport receives. */ startBatch(aliases: readonly string[], groupId: string, ordinal: number): DecisionRuntimeSpan | undefined; /** * Close one batch plan. A durable receipt is the accounting authority and is * bridged through `recordBatchReceiptTrace`; without one, shared usage comes * from the single transport response. A replayed receipt dispatched nothing * here, so it only links back to the trace that created it. */ finishBatch(handles: readonly DecisionRuntimeSpan[], receipt: DecisionBatchReceipt | undefined): void; /** Link the workflow to the trace that created a durable receipt this invocation is replaying. */ linkOrigin(traceParent: string | undefined, relationship: DecisionTelemetryLink['relationship'], attributes: TelemetryAttributes): void; /** Record normalize/accept for one finished evaluation, linked to any shared batch request. */ decided(result: DecisionResult): void; /** Close the workflow and flush. Exporter and metric failures are isolated per span. */ finish(result: RulesetResult): Promise; private open; private guard; } /** The live trace bound to this evaluator request, if telemetry is configured and healthy. */ export declare function runtimeTraceOf(request: DecisionEvaluationRequest): DecisionRuntimeTrace | null; //# sourceMappingURL=runtime.d.ts.map