/** * S1 auto-derive — wrap-layer before/after pair from the tool call + current-state readers. * * Default OFF. Frozen guardToolCall is unchanged. Host args.artifacts always win. * BEFORE comes from a reader of the SAME target (fs path / api / db / registry). * AFTER is the call's intended write content. Missing target → before:null * (derivation_note before_unavailable); empty file → before:"". * * Reader throw/timeout → today's fragment path (binder lift); never block on derivation. * Observation-only: derivation is not a fingerprint preimage field. */ import type { ArtifactType, ResolveConfig } from './artifact-resolver.js'; import type { GuardConfig, ToolCallDescriptor } from './types.js'; export declare const AUTO_DERIVE_SOURCE: "guard_auto_derived"; export declare const AUTO_DERIVE_READ_TIMEOUT_MS = 2000; export type AutoDeriveMode = 'host_supplied' | 'auto_derived' | 'fragment_only'; export type AutoDeriveTargetKind = 'fs' | 'api' | 'db' | 'registry'; export type AutoDeriveTarget = { kind: AutoDeriveTargetKind; key: string; }; export type AutoDeriveNote = { target: string; note: 'before_unavailable' | 'reader_threw' | 'reader_timeout' | 'not_contract_path'; }; export type AutoDeriveObservation = { derivation?: { mode: AutoDeriveMode; targets: ReadonlyArray; notes?: ReadonlyArray; }; }; export type AutoDeriveReader = (key: string) => string | null | Promise; /** Current-state readers. Return null = absent (not empty). Throw/timeout → fragment fallback. */ export type AutoDeriveReaders = { fs?: AutoDeriveReader; api?: AutoDeriveReader; db?: AutoDeriveReader; registry?: AutoDeriveReader; }; export type AutoDeriveConfig = { readers?: AutoDeriveReaders; /** CAP-202 resolve() config (pathTypeHints, ssotPrefer). Optional; not required for fs reads. */ resolveConfig?: ResolveConfig; }; export type DerivedArtifact = { id: string; type: ArtifactType; before: string | null; after: string; source: typeof AUTO_DERIVE_SOURCE; }; /** Default fs reader: utf8 contents, ENOENT → null (absent ≠ empty). Other errors throw. */ export declare function defaultFsReader(filePath: string): Promise; export declare function normalizeAutoDerive(raw: unknown): AutoDeriveConfig | null; export type AutoDeriveResult = { call: ToolCallDescriptor; derivation: NonNullable; failed?: { cause: string; }; }; /** * Derive a before/after pair onto the call descriptor when the host did not supply artifacts. * Never throws out — reader failures return the bound call with fragment_only + failed.cause. */ export declare function runAutoDerive(args: { bound: ToolCallDescriptor; rawArgs: unknown; cfg: AutoDeriveConfig; config: GuardConfig; }): Promise; export declare function attachDerivation(outcome: T, derivation: NonNullable | null | undefined): T; //# sourceMappingURL=auto-derive.d.ts.map