@contractspec/lib.evolution 0.0.0-canary-20260113162409

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { AnomalySeverity, EvolutionConfig, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnomaly, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus } from "./types.mjs";
2
+ import { SpecAnalyzer, SpecAnalyzerOptions } from "./analyzer/spec-analyzer.mjs";
3
+ import { GenerateSpecOptions, SpecGenerator, SpecGeneratorOptions, SpecPatch } from "./generator/spec-generator.mjs";
4
+ import { AISpecGenerator, AISpecGeneratorConfig, createAISpecGenerator } from "./generator/ai-spec-generator.mjs";
5
+ import { FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions } from "./approval/integration.mjs";
6
+ export { AISpecGenerator, AISpecGeneratorConfig, AnomalySeverity, EvolutionConfig, FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, GenerateSpecOptions, InMemorySpecSuggestionRepository, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnalyzer, SpecAnalyzerOptions, SpecAnomaly, SpecGenerator, SpecGeneratorOptions, SpecPatch, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus, createAISpecGenerator };
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { SpecAnalyzer } from "./analyzer/spec-analyzer.mjs";
2
+ import { SpecGenerator } from "./generator/spec-generator.mjs";
3
+ import { AISpecGenerator, createAISpecGenerator } from "./generator/ai-spec-generator.mjs";
4
+ import { FileSystemSuggestionWriter, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator } from "./approval/integration.mjs";
5
+
6
+ export { AISpecGenerator, FileSystemSuggestionWriter, InMemorySpecSuggestionRepository, SpecAnalyzer, SpecGenerator, SpecSuggestionOrchestrator, createAISpecGenerator };
@@ -0,0 +1,132 @@
1
+ import { LifecycleStage } from "@contractspec/lib.lifecycle";
2
+ import { OpKind, OperationSpec, ResourceRefDescriptor } from "@contractspec/lib.contracts";
3
+ import { AnySchemaModel } from "@contractspec/lib.schema";
4
+
5
+ //#region src/types.d.ts
6
+ type AnomalySeverity = 'low' | 'medium' | 'high';
7
+ type SuggestionStatus = 'pending' | 'approved' | 'rejected';
8
+ interface OperationCoordinate {
9
+ key: string;
10
+ version: string;
11
+ tenantId?: string;
12
+ }
13
+ interface OperationMetricSample {
14
+ operation: OperationCoordinate;
15
+ durationMs: number;
16
+ success: boolean;
17
+ timestamp: Date;
18
+ payloadSizeBytes?: number;
19
+ errorCode?: string;
20
+ errorMessage?: string;
21
+ actor?: string;
22
+ channel?: string;
23
+ traceId?: string;
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ interface SpecUsageStats {
27
+ operation: OperationCoordinate;
28
+ totalCalls: number;
29
+ successRate: number;
30
+ errorRate: number;
31
+ averageLatencyMs: number;
32
+ p95LatencyMs: number;
33
+ p99LatencyMs: number;
34
+ maxLatencyMs: number;
35
+ lastSeenAt: Date;
36
+ windowStart: Date;
37
+ windowEnd: Date;
38
+ topErrors: Record<string, number>;
39
+ }
40
+ interface SuggestionEvidence {
41
+ type: 'telemetry' | 'user-feedback' | 'simulation' | 'test';
42
+ description: string;
43
+ data?: Record<string, unknown>;
44
+ }
45
+ interface SpecAnomaly {
46
+ operation: OperationCoordinate;
47
+ severity: AnomalySeverity;
48
+ metric: 'latency' | 'error-rate' | 'throughput' | 'policy' | 'schema';
49
+ description: string;
50
+ detectedAt: Date;
51
+ threshold?: number;
52
+ observedValue?: number;
53
+ evidence: SuggestionEvidence[];
54
+ }
55
+ interface PatternConfidence {
56
+ score: number;
57
+ sampleSize: number;
58
+ pValue?: number;
59
+ }
60
+ interface IntentPattern {
61
+ id: string;
62
+ type: 'latency-regression' | 'error-spike' | 'missing-operation' | 'chained-intent' | 'throughput-drop' | 'schema-mismatch';
63
+ description: string;
64
+ operation?: OperationCoordinate;
65
+ confidence: PatternConfidence;
66
+ metadata?: Record<string, unknown>;
67
+ evidence: SuggestionEvidence[];
68
+ }
69
+ interface SpecSuggestionProposal {
70
+ summary: string;
71
+ rationale: string;
72
+ changeType: 'new-spec' | 'revision' | 'policy-update' | 'schema-update';
73
+ kind?: OpKind;
74
+ spec?: OperationSpec<AnySchemaModel, AnySchemaModel | ResourceRefDescriptor<boolean>>;
75
+ diff?: string;
76
+ metadata?: Record<string, unknown>;
77
+ }
78
+ interface SpecSuggestion {
79
+ id: string;
80
+ intent: IntentPattern;
81
+ target?: OperationCoordinate;
82
+ proposal: SpecSuggestionProposal;
83
+ confidence: number;
84
+ createdAt: Date;
85
+ createdBy: string;
86
+ status: SuggestionStatus;
87
+ evidence: SuggestionEvidence[];
88
+ priority: 'low' | 'medium' | 'high';
89
+ tags?: string[];
90
+ approvals?: {
91
+ reviewer?: string;
92
+ notes?: string;
93
+ decidedAt?: Date;
94
+ status?: SuggestionStatus;
95
+ };
96
+ }
97
+ interface EvolutionConfig {
98
+ minConfidence?: number;
99
+ autoApproveThreshold?: number;
100
+ maxSuggestionsPerOperation?: number;
101
+ requireApproval?: boolean;
102
+ maxConcurrentExperiments?: number;
103
+ }
104
+ interface SpecSuggestionFilters {
105
+ status?: SuggestionStatus;
106
+ operationKey?: string;
107
+ }
108
+ interface SpecSuggestionRepository {
109
+ create(suggestion: SpecSuggestion): Promise<void>;
110
+ getById(id: string): Promise<SpecSuggestion | undefined>;
111
+ updateStatus(id: string, status: SuggestionStatus, metadata?: {
112
+ reviewer?: string;
113
+ notes?: string;
114
+ decidedAt?: Date;
115
+ }): Promise<void>;
116
+ list(filters?: SpecSuggestionFilters): Promise<SpecSuggestion[]>;
117
+ }
118
+ interface SpecSuggestionWriter {
119
+ write(suggestion: SpecSuggestion): Promise<string>;
120
+ }
121
+ interface OptimizationHint {
122
+ operation: OperationCoordinate;
123
+ category: 'schema' | 'policy' | 'performance' | 'error-handling';
124
+ summary: string;
125
+ justification: string;
126
+ recommendedActions: string[];
127
+ lifecycleStage?: LifecycleStage;
128
+ lifecycleNotes?: string;
129
+ }
130
+ //#endregion
131
+ export { AnomalySeverity, EvolutionConfig, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnomaly, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus };
132
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;KAQY,eAAA;KACA,gBAAA;AADA,UAGK,mBAAA,CAHU;EACf,GAAA,EAAA,MAAA;EAEK,OAAA,EAAA,MAAA;EAMA,QAAA,CAAA,EAAA,MAAA;;AAIJ,UAJI,qBAAA,CAIJ;EAOA,SAAA,EAVA,mBAUA;EAAM,UAAA,EAAA,MAAA;EAGF,OAAA,EAAA,OAAA;EACJ,SAAA,EAXA,IAWA;EAQC,gBAAA,CAAA,EAAA,MAAA;EACC,SAAA,CAAA,EAAA,MAAA;EACF,YAAA,CAAA,EAAA,MAAA;EACA,KAAA,CAAA,EAAA,MAAA;EAAM,OAAA,CAAA,EAAA,MAAA;EAGF,OAAA,CAAA,EAAA,MAAA;EAMA,QAAA,CAAA,EAxBJ,MAwBe,CAAA,MAAA,EAAA,OAAA,CAAA;;AAEhB,UAvBK,cAAA,CAuBL;EAGE,SAAA,EAzBD,mBAyBC;EAGF,UAAA,EAAA,MAAA;EAAkB,WAAA,EAAA,MAAA;EAGb,SAAA,EAAA,M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AAiB;;aAGR;;UAGI,cAAA;;UAEP;WACC;YACC;;aAEC;;UAEH;YACE;;;;;;gBAMI;aACH;;;UAII,eAAA;;;;;;;UAQA,qBAAA;WACN;;;UAIM,wBAAA;qBACI,iBAAiB;uBACf,QAAQ;mCAGnB;;;gBACoD;MAC3D;iBACY,wBAAwB,QAAQ;;UAGhC,oBAAA;oBACG,iBAAiB;;UAGpB,gBAAA;aACJ;;;;;mBAKM"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@contractspec/lib.evolution",
3
+ "version": "0.0.0-canary-20260113162409",
4
+ "description": "AI-powered contract evolution engine",
5
+ "keywords": [
6
+ "contractspec",
7
+ "evolution",
8
+ "ai",
9
+ "automation",
10
+ "typescript"
11
+ ],
12
+ "type": "module",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
20
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
21
+ "build": "bun build:types && bun build:bundle",
22
+ "build:bundle": "tsdown",
23
+ "build:types": "tsc --noEmit",
24
+ "dev": "bun build:bundle --watch",
25
+ "clean": "rimraf dist .turbo",
26
+ "lint": "bun lint:fix",
27
+ "lint:fix": "eslint src --fix",
28
+ "lint:check": "eslint src",
29
+ "test": "bun test"
30
+ },
31
+ "dependencies": {
32
+ "ai": "6.0.29",
33
+ "zod": "^4.3.5",
34
+ "@contractspec/lib.ai-agent": "0.0.0-canary-20260113162409",
35
+ "@contractspec/lib.contracts": "0.0.0-canary-20260113162409",
36
+ "@contractspec/lib.lifecycle": "0.0.0-canary-20260113162409",
37
+ "@contractspec/lib.observability": "0.0.0-canary-20260113162409",
38
+ "@contractspec/lib.schema": "0.0.0-canary-20260113162409"
39
+ },
40
+ "peerDependencies": {
41
+ "@prisma/client": "7.2.0"
42
+ },
43
+ "devDependencies": {
44
+ "@contractspec/tool.tsdown": "0.0.0-canary-20260113162409",
45
+ "@contractspec/tool.typescript": "0.0.0-canary-20260113162409",
46
+ "tsdown": "^0.19.0",
47
+ "typescript": "^5.9.3"
48
+ },
49
+ "exports": {
50
+ ".": "./dist/index.mjs",
51
+ "./*": "./*"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "exports": {
56
+ ".": "./dist/index.js",
57
+ "./*": "./*"
58
+ },
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "license": "MIT",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://github.com/lssm-tech/contractspec.git",
65
+ "directory": "packages/libs/evolution"
66
+ },
67
+ "homepage": "https://contractspec.io"
68
+ }