/** * Learning Provenance Metadata Types (CX-006) * * Provides tracking of: * - Pattern source: How/where the pattern was learned * - Last verified: When the pattern was last confirmed to work * - Decay history: Why and when confidence was reduced * * This enables LLM clients to understand: * - Trustworthiness of learned patterns * - Age and freshness of knowledge * - History of pattern reliability */ /** * How a pattern was learned/discovered */ export type PatternSource = 'bootstrap' | 'api_extraction' | 'openapi_discovery' | 'graphql_introspection' | 'asyncapi_discovery' | 'alt_spec_discovery' | 'docs_page_detection' | 'link_discovery' | 'robots_sitemap' | 'backend_fingerprinting' | 'cross_site_transfer' | 'user_feedback' | 'manual' | 'unknown'; /** * Reasons why confidence may have decayed */ export type ConfidenceDecayReason = 'time_decay' | 'repeated_failures' | 'validation_failures' | 'site_structure_changed' | 'rate_limited' | 'auth_expired' | 'pattern_archived' | 'manual_downgrade'; /** * Record of a confidence decay event */ export interface DecayEvent { /** When the decay occurred */ timestamp: number; /** Why confidence was reduced */ reason: ConfidenceDecayReason; /** Confidence level before decay (0-1 or 'high'/'medium'/'low') */ previousConfidence: number | 'high' | 'medium' | 'low'; /** Confidence level after decay (0-1 or 'high'/'medium'/'low') */ newConfidence: number | 'high' | 'medium' | 'low'; /** Additional context about the decay */ details?: string; } /** * Provenance metadata for learned patterns * * Tracks the origin and history of a pattern to enable: * - Trust assessment (is this pattern reliable?) * - Freshness evaluation (is this pattern up-to-date?) * - Debugging (why did confidence change?) */ export interface ProvenanceMetadata { /** How this pattern was learned/discovered */ source: PatternSource; /** URL where the pattern was discovered (e.g., OpenAPI spec URL) */ sourceUrl?: string; /** ID of the source pattern (for transferred patterns) */ sourcePatternId?: string; /** Domain the pattern was originally learned from */ sourceDomain?: string; /** When this pattern was first learned */ learnedAt: number; /** Who/what created this pattern (for audit trail) */ createdBy?: string; /** When this pattern was last verified to work */ lastVerifiedAt?: number; /** When this pattern was last used (attempted, regardless of success) */ lastUsedAt?: number; /** Number of times this pattern has been verified */ verificationCount: number; /** History of confidence decay events (most recent first, max 10) */ decayHistory?: DecayEvent[]; /** Tags for categorization/filtering */ tags?: string[]; /** Additional metadata from the source */ sourceMetadata?: Record; } /** * Create initial provenance metadata for a newly learned pattern */ export declare function createProvenance(source: PatternSource, options?: { sourceUrl?: string; sourcePatternId?: string; sourceDomain?: string; createdBy?: string; tags?: string[]; sourceMetadata?: Record; }): ProvenanceMetadata; /** * Record a pattern verification (successful use) */ export declare function recordVerification(provenance: ProvenanceMetadata): ProvenanceMetadata; /** * Record pattern usage (regardless of success) */ export declare function recordUsage(provenance: ProvenanceMetadata): ProvenanceMetadata; /** * Record a confidence decay event */ export declare function recordDecay(provenance: ProvenanceMetadata, reason: ConfidenceDecayReason, previousConfidence: number | 'high' | 'medium' | 'low', newConfidence: number | 'high' | 'medium' | 'low', details?: string): ProvenanceMetadata; /** * Check if provenance indicates the pattern is stale * (not verified within the specified number of days) */ export declare function isStale(provenance: ProvenanceMetadata, staleDays?: number): boolean; /** * Get days since last verification */ export declare function getDaysSinceVerification(provenance: ProvenanceMetadata): number; /** * Get human-readable provenance summary */ export declare function getProvenanceSummary(provenance: ProvenanceMetadata): string; //# sourceMappingURL=provenance.d.ts.map