/** * Attribution Attestation Types and Validators (v0.9.26+) * * Provides content derivation and usage proof for PEAC receipts, * enabling chain tracking and compliance artifacts. * * @see docs/specs/ATTRIBUTION.md for normative specification */ import { z } from 'zod'; import type { JsonValue } from '@peac/kernel'; /** * Attribution limits for DoS protection and verification feasibility. * * These are implementation safety limits, not protocol constraints. */ export declare const ATTRIBUTION_LIMITS: { /** Maximum sources per attestation */ readonly maxSources: 100; /** Maximum chain resolution depth */ readonly maxDepth: 8; /** Maximum attestation size in bytes (64KB) */ readonly maxAttestationSize: 65536; /** Per-hop resolution timeout in milliseconds */ readonly resolutionTimeout: 5000; /** Maximum receipt reference length */ readonly maxReceiptRefLength: 2048; /** Maximum model ID length */ readonly maxModelIdLength: 256; }; /** * Supported hash algorithms for content hashing. * Only sha-256 is supported in v0.9.26. */ export declare const HashAlgorithmSchema: z.ZodLiteral<"sha-256">; export type HashAlgorithm = z.infer; /** * Supported encoding formats for hash values. */ export declare const HashEncodingSchema: z.ZodLiteral<"base64url">; export type HashEncoding = z.infer; /** * ContentHash - deterministic content identification. * * Provides cryptographic verification of content identity using SHA-256. * The hash value is base64url-encoded without padding (RFC 4648 Section 5). * * @example * ```typescript * const hash: ContentHash = { * alg: 'sha-256', * value: 'n4bQgYhMfWWaL28IoEbM8Qa8jG7x0QXJZJqL-w_zZdA', * enc: 'base64url', * }; * ``` */ export declare const ContentHashSchema: z.ZodObject<{ alg: z.ZodLiteral<"sha-256">; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>; export type ContentHash = z.infer; /** * How source content was used in derivation. * * - 'training_input': Used to train a model * - 'rag_context': Retrieved for RAG context * - 'direct_reference': Directly quoted or referenced * - 'synthesis_source': Combined with other sources to create new content * - 'embedding_source': Used to create embeddings/vectors */ export declare const AttributionUsageSchema: z.ZodEnum<{ training_input: "training_input"; rag_context: "rag_context"; direct_reference: "direct_reference"; synthesis_source: "synthesis_source"; embedding_source: "embedding_source"; }>; export type AttributionUsage = z.infer; /** * Array of valid attribution usage types for runtime checks. */ export declare const ATTRIBUTION_USAGES: readonly ["training_input", "rag_context", "direct_reference", "synthesis_source", "embedding_source"]; /** * Type of content derivation. * * - 'training': Model training or fine-tuning * - 'inference': Runtime inference with RAG/grounding * - 'rag': Retrieval-augmented generation * - 'synthesis': Multi-source content synthesis * - 'embedding': Vector embedding generation */ export declare const DerivationTypeSchema: z.ZodEnum<{ training: "training"; inference: "inference"; rag: "rag"; synthesis: "synthesis"; embedding: "embedding"; }>; export type DerivationType = z.infer; /** * Array of valid derivation types for runtime checks. */ export declare const DERIVATION_TYPES: readonly ["training", "inference", "rag", "synthesis", "embedding"]; /** * AttributionSource - links to a source receipt and describes how content was used. * * For cross-issuer resolution, include `receipt_issuer` when using `jti:*` references. * URL-based references (`https://...`) are self-resolvable. * * @example * ```typescript * const source: AttributionSource = { * receipt_ref: 'jti:rec_abc123def456', * receipt_issuer: 'https://publisher.example.com', * content_hash: { alg: 'sha-256', value: '...', enc: 'base64url' }, * usage: 'rag_context', * weight: 0.3, * }; * ``` */ export declare const AttributionSourceSchema: z.ZodObject<{ receipt_ref: z.ZodString; receipt_issuer: z.ZodOptional; content_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; excerpt_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; usage: z.ZodEnum<{ training_input: "training_input"; rag_context: "rag_context"; direct_reference: "direct_reference"; synthesis_source: "synthesis_source"; embedding_source: "embedding_source"; }>; weight: z.ZodOptional; }, z.core.$strict>; export type AttributionSource = z.infer; /** * AttributionEvidence - the payload of an AttributionAttestation. * * Contains the sources, derivation type, and optional output metadata. */ export declare const AttributionEvidenceSchema: z.ZodObject<{ sources: z.ZodArray; content_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; excerpt_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; usage: z.ZodEnum<{ training_input: "training_input"; rag_context: "rag_context"; direct_reference: "direct_reference"; synthesis_source: "synthesis_source"; embedding_source: "embedding_source"; }>; weight: z.ZodOptional; }, z.core.$strict>>; derivation_type: z.ZodEnum<{ training: "training"; inference: "inference"; rag: "rag"; synthesis: "synthesis"; embedding: "embedding"; }>; output_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; model_id: z.ZodOptional; inference_provider: z.ZodOptional; session_id: z.ZodOptional; metadata: z.ZodOptional>>>; }, z.core.$strict>; export type AttributionEvidence = z.infer; /** * Attestation type literal for attribution */ export declare const ATTRIBUTION_TYPE: "peac/attribution"; /** * AttributionAttestation - proves content derivation and usage. * * This attestation provides cryptographic evidence that content was derived * from specific sources, enabling chain tracking and compliance. * * @example * ```typescript * const attestation: AttributionAttestation = { * type: 'peac/attribution', * issuer: 'https://ai.example.com', * issued_at: '2026-01-04T12:00:00Z', * evidence: { * sources: [ * { receipt_ref: 'jti:rec_abc123', usage: 'rag_context', weight: 0.5 }, * { receipt_ref: 'jti:rec_def456', usage: 'rag_context', weight: 0.5 }, * ], * derivation_type: 'rag', * model_id: 'gpt-4', * }, * }; * ``` */ export declare const AttributionAttestationSchema: z.ZodObject<{ type: z.ZodLiteral<"peac/attribution">; issuer: z.ZodString; issued_at: z.ZodString; expires_at: z.ZodOptional; ref: z.ZodOptional; evidence: z.ZodObject<{ sources: z.ZodArray; content_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; excerpt_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; usage: z.ZodEnum<{ training_input: "training_input"; rag_context: "rag_context"; direct_reference: "direct_reference"; synthesis_source: "synthesis_source"; embedding_source: "embedding_source"; }>; weight: z.ZodOptional; }, z.core.$strict>>; derivation_type: z.ZodEnum<{ training: "training"; inference: "inference"; rag: "rag"; synthesis: "synthesis"; embedding: "embedding"; }>; output_hash: z.ZodOptional; value: z.ZodString; enc: z.ZodLiteral<"base64url">; }, z.core.$strict>>; model_id: z.ZodOptional; inference_provider: z.ZodOptional; session_id: z.ZodOptional; metadata: z.ZodOptional>>>; }, z.core.$strict>; }, z.core.$strict>; export type AttributionAttestation = z.infer; /** * Result of chain verification including depth and resolved sources. */ export interface ChainVerificationResult { /** Whether the chain is valid */ valid: boolean; /** Maximum depth encountered in the chain */ maxDepth: number; /** Total number of sources across the chain */ totalSources: number; /** Any cycle detected in the chain */ cycleDetected?: string; /** Error message if validation failed */ error?: string; } /** * Validate a ContentHash. * * @param data - Unknown data to validate * @returns Result with validated hash or error message */ export declare function validateContentHash(data: unknown): { ok: true; value: ContentHash; } | { ok: false; error: string; }; /** * Validate an AttributionSource. * * @param data - Unknown data to validate * @returns Result with validated source or error message */ export declare function validateAttributionSource(data: unknown): { ok: true; value: AttributionSource; } | { ok: false; error: string; }; /** * Validate an AttributionAttestation. * * @param data - Unknown data to validate * @returns Result with validated attestation or error message * * @example * ```typescript * const result = validateAttributionAttestation(data); * if (result.ok) { * console.log('Sources:', result.value.evidence.sources.length); * } else { * console.error('Validation error:', result.error); * } * ``` */ export declare function validateAttributionAttestation(data: unknown): { ok: true; value: AttributionAttestation; } | { ok: false; error: string; }; /** * Check if an object is an AttributionAttestation. * * @param attestation - Object with a type field * @returns True if the type is 'peac/attribution' */ export declare function isAttributionAttestation(attestation: { type: string; }): attestation is AttributionAttestation; /** * Parameters for creating an AttributionAttestation. */ export interface CreateAttributionAttestationParams { /** Issuer of the attestation */ issuer: string; /** Attribution sources */ sources: AttributionSource[]; /** Type of derivation */ derivation_type: DerivationType; /** Hash of derived output (optional) */ output_hash?: ContentHash; /** Model identifier (optional) */ model_id?: string; /** Inference provider URL (optional) */ inference_provider?: string; /** Session correlation ID (optional) */ session_id?: string; /** When the attestation expires (optional) */ expires_at?: string; /** External verification endpoint (optional) */ ref?: string; /** Additional metadata (optional, must be JSON-safe) */ metadata?: Record; } /** * Create an AttributionAttestation with current timestamp. * * @param params - Attestation parameters * @returns A valid AttributionAttestation * * @example * ```typescript * const attestation = createAttributionAttestation({ * issuer: 'https://ai.example.com', * sources: [ * { receipt_ref: 'jti:rec_abc123', usage: 'rag_context' }, * ], * derivation_type: 'rag', * model_id: 'gpt-4', * }); * ``` */ export declare function createAttributionAttestation(params: CreateAttributionAttestationParams): AttributionAttestation; /** * Check if an attribution attestation is expired. * * @param attestation - The attestation to check * @param clockSkew - Optional clock skew tolerance in milliseconds (default: 30000) * @returns True if the attestation has expired */ export declare function isAttributionExpired(attestation: AttributionAttestation, clockSkew?: number): boolean; /** * Check if an attribution attestation is not yet valid. * * @param attestation - The attestation to check * @param clockSkew - Optional clock skew tolerance in milliseconds (default: 30000) * @returns True if the attestation is not yet valid (issued_at in the future) */ export declare function isAttributionNotYetValid(attestation: AttributionAttestation, clockSkew?: number): boolean; /** * Compute total weight of sources (for validation). * * @param sources - Array of attribution sources * @returns Total weight, or undefined if no weights specified */ export declare function computeTotalWeight(sources: AttributionSource[]): number | undefined; /** * Detect cycles in attribution sources (for chain validation). * * @param sources - Array of attribution sources * @param visited - Set of visited receipt refs (for recursion) * @returns Receipt ref that caused cycle, or undefined if no cycle */ export declare function detectCycleInSources(sources: AttributionSource[], visited?: Set): string | undefined; //# sourceMappingURL=attribution.d.ts.map