/** * Decision-offload checkpoint execution and offline adoption reporting. * * Opportunity records describe only checkpoints that called this contract. * Generic activity-log prose is deliberately not interpreted as a precise * opportunity denominator. Completed-call records remain in ledger.ts; the * shared correlation id joins the two append-only journals. */ import { askDecision, type DecisionAskInput, type DecisionAskResult, type DecisionAskRuntimeOptions } from './ask.js'; import { recordDecisionAsk, type DecisionLedgerTransport, type RecordDecisionAskOptions } from './ledger.js'; export declare const DECISION_OPPORTUNITY_SCHEMA: "aiwg-decision-opportunity/v1"; export declare const DECISION_OFFLOAD_SNAPSHOT_SCHEMA: "aiwg-decision-offload-snapshot/v1"; export declare const DECISION_OPPORTUNITY_RECORD_TIMEOUT_MS = 250; export type DecisionOffloadCategory = 'organic' | 'diagnostic' | 'setup' | 'benchmark' | 'unattributed'; export type DecisionOpportunityOutcome = 'answered' | 'fallback' | 'skipped' | 'unknown'; export type DecisionOpportunitySkipReason = 'disabled' | 'missing-addon' | 'privacy-excluded' | 'budget-excluded' | 'action-excluded' | 'usage-rejected' | 'checkpoint-unsupported' | 'other-exclusion'; export interface DecisionOpportunityRecord { schema: typeof DECISION_OPPORTUNITY_SCHEMA; correlationId: string; timestamp: string; phase: 'started' | 'completed' | 'skipped'; provider: string; sessionId: string; sessionSource: string; transport: DecisionLedgerTransport | 'internal'; caller: string; category: DecisionOffloadCategory; eligible: boolean; attempted: boolean; outcome: DecisionOpportunityOutcome; reason: string; ledgerRecorded: boolean | null; } export interface DecisionCheckpointEligibility { eligible: boolean; reason?: DecisionOpportunitySkipReason; } export interface RunDecisionOffloadCheckpointOptions extends Omit { caller: string; /** Preserve the public ask ledger's optional caller while the opportunity keeps an executable checkpoint identity. */ ledgerCaller?: string | null; category?: DecisionOffloadCategory; eligibility?: DecisionCheckpointEligibility; askRuntime?: DecisionAskRuntimeOptions; id?: () => string; ask?: typeof askDecision; recordAsk?: typeof recordDecisionAsk; appendOpportunity?: (record: DecisionOpportunityRecord, projectRoot: string, warn?: (message: string) => void) => Promise; /** Bounds each opportunity append independently; test override, defaults to the ledger's 250ms bound. */ opportunityTimeoutMs?: number; /** Bounds provider attribution before the pre-call record; test override, defaults to 250ms. */ providerTimeoutMs?: number; } export type DecisionOffloadCheckpointResult = { outcome: 'answered' | 'fallback'; result: DecisionAskResult; opportunity: DecisionOpportunityRecord; attemptRecorded: boolean | null; opportunityRecorded: boolean | null; } | { outcome: 'skipped'; result: null; opportunity: DecisionOpportunityRecord; opportunityRecorded: boolean | null; } | { outcome: 'unknown'; result: null; opportunity: DecisionOpportunityRecord; attemptRecorded: boolean | null; opportunityRecorded: boolean | null; error: unknown; }; export interface DecisionOffloadActivationEvidence { ruleSourceAvailable?: boolean | null; addon: 'installed' | 'missing' | 'unknown'; ruleDelivery: 'present' | 'missing' | 'unknown'; startupAnchor: 'present' | 'missing' | 'unknown'; nativeActivation: 'verified' | 'not-claimed' | 'unknown'; source?: string; } export interface DecisionOffloadThresholds { minimumEligible: number; minimumAttemptRate: number; repeatedFallbacks: number; } export interface BuildDecisionOffloadSnapshotOptions { projectRoot: string; /** Package/framework root used by the activation inspector during final integration. */ frameworkRoot?: string; sessionId?: string; windowHours?: number; env?: NodeJS.ProcessEnv; now?: Date; activationEvidence?: Partial; thresholds?: Partial; } export declare const DECISION_OFFLOAD_CHECKPOINT_COVERAGE: { caller: string; coverage: "instruction-only"; }[]; export declare const DECISION_OFFLOAD_EXECUTABLE_COVERAGE: ({ entrypoint: string; transport: "cli"; coverage: "shared-contract-generic"; } | { entrypoint: string; transport: "mcp"; coverage: "shared-contract-generic"; })[]; export declare function decisionOffloadCategory(caller: string | null | undefined): DecisionOffloadCategory; export declare function appendDecisionOpportunity(record: DecisionOpportunityRecord, projectRoot: string, warn?: (message: string) => void): Promise; export declare function runDecisionOffloadCheckpoint(input: DecisionAskInput, options: RunDecisionOffloadCheckpointOptions): Promise; export declare function buildDecisionOffloadSnapshot(options: BuildDecisionOffloadSnapshotOptions): Promise<{ schema: "aiwg-decision-offload-snapshot/v1"; scope: { projectRoot: string; mode: string; sessionId: string | null; since: string | null; windowHours: number | null; generatedAt: string; }; readiness: { ask: { probed: boolean; path?: string | undefined; state: "unknown" | "disabled" | "fallback" | "reachable" | "configured-unprobed"; configured: boolean | null; enabled: boolean | null; source: "unknown" | "none" | "file" | "env" | "openbao"; }; evaluate: { state: string; enabled: boolean | null; source: string; probed: boolean; }; observed: { timestamp: string; transport: "internal" | DecisionLedgerTransport; category: DecisionOffloadCategory; outcome: DecisionOpportunityOutcome; reason: string; } | null; }; activation: DecisionOffloadActivationEvidence; coverage: { executable: ({ entrypoint: string; transport: "cli"; coverage: "shared-contract-generic"; } | { entrypoint: string; transport: "mcp"; coverage: "shared-contract-generic"; })[]; instructionOnly: { caller: string; coverage: "instruction-only"; }[]; unsupportedObservation: string; }; opportunities: { organic: { observed: number; eligible: number; attempted: number; answered: number; fallback: number; skipped: number; unknown: number; usageRejected: number; ledgerRecordingUnknown: number; reasons: Record; }; excluded: { observed: number; eligible: number; attempted: number; answered: number; fallback: number; skipped: number; unknown: number; usageRejected: number; ledgerRecordingUnknown: number; reasons: Record; }; journalEvents: number; invalidRecords: number; journal: "absent" | "available" | "unreadable"; }; calls: { organic: { completed: number; answered: number; fallback: number; fallbackReasons: Record; llmTokensAvoided: number; jevTokens: number; }; excluded: { completed: number; answered: number; fallback: number; fallbackReasons: Record; llmTokensAvoided: number; jevTokens: number; }; invalidRecords: number; }; activityHint: { status: string; reason: string | null; suppressionReason: string | null; recognizableOrchestrationEvents: number; eligibleCount: string; confidence: string; scope: string; source: string | null; journal: "absent" | "available" | "unreadable"; note: string; }; correlation: { matched: number; attemptedWithoutLedger: number; organicAttemptedWithoutLedger: number; ledgerWithoutOpportunity: number; }; drift: { status: string; advisory: boolean; reasons: string[]; thresholds: DecisionOffloadThresholds; thresholdSource: string; note: string | null; }; }>; //# sourceMappingURL=offload.d.ts.map