@contractspec/lib.evolution 1.44.0
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.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/ai-agent/src/approval/index.d.ts +1 -0
- package/dist/ai-agent/src/approval/workflow.d.ts +136 -0
- package/dist/ai-agent/src/approval/workflow.d.ts.map +1 -0
- package/dist/ai-agent/src/types.d.ts +30 -0
- package/dist/ai-agent/src/types.d.ts.map +1 -0
- package/dist/analyzer/spec-analyzer.d.ts +35 -0
- package/dist/analyzer/spec-analyzer.d.ts.map +1 -0
- package/dist/analyzer/spec-analyzer.js +305 -0
- package/dist/analyzer/spec-analyzer.js.map +1 -0
- package/dist/approval/integration.d.ts +44 -0
- package/dist/approval/integration.d.ts.map +1 -0
- package/dist/approval/integration.js +126 -0
- package/dist/approval/integration.js.map +1 -0
- package/dist/generator/ai-spec-generator.d.ts +56 -0
- package/dist/generator/ai-spec-generator.d.ts.map +1 -0
- package/dist/generator/ai-spec-generator.js +186 -0
- package/dist/generator/ai-spec-generator.js.map +1 -0
- package/dist/generator/spec-generator.d.ts +46 -0
- package/dist/generator/spec-generator.d.ts.map +1 -0
- package/dist/generator/spec-generator.js +121 -0
- package/dist/generator/spec-generator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/types.d.ts +132 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnomalySeverity, EvolutionConfig, IntentPattern, OperationCoordinate, OperationMetricSample, OptimizationHint, PatternConfidence, SpecAnomaly, SpecSuggestion, SpecSuggestionFilters, SpecSuggestionProposal, SpecSuggestionRepository, SpecSuggestionWriter, SpecUsageStats, SuggestionEvidence, SuggestionStatus } from "./types.js";
|
|
2
|
+
import { SpecAnalyzer, SpecAnalyzerOptions } from "./analyzer/spec-analyzer.js";
|
|
3
|
+
import { GenerateSpecOptions, SpecGenerator, SpecGeneratorOptions, SpecPatch } from "./generator/spec-generator.js";
|
|
4
|
+
import { AISpecGenerator, AISpecGeneratorConfig, createAISpecGenerator } from "./generator/ai-spec-generator.js";
|
|
5
|
+
import { FileSystemSuggestionWriter, FileSystemSuggestionWriterOptions, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator, SpecSuggestionOrchestratorOptions } from "./approval/integration.js";
|
|
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.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SpecAnalyzer } from "./analyzer/spec-analyzer.js";
|
|
2
|
+
import { SpecGenerator } from "./generator/spec-generator.js";
|
|
3
|
+
import { AISpecGenerator, createAISpecGenerator } from "./generator/ai-spec-generator.js";
|
|
4
|
+
import { FileSystemSuggestionWriter, InMemorySpecSuggestionRepository, SpecSuggestionOrchestrator } from "./approval/integration.js";
|
|
5
|
+
|
|
6
|
+
export { AISpecGenerator, FileSystemSuggestionWriter, InMemorySpecSuggestionRepository, SpecAnalyzer, SpecGenerator, SpecSuggestionOrchestrator, createAISpecGenerator };
|
package/dist/types.d.ts
ADDED
|
@@ -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: number;
|
|
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.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.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,EAAA,MAAA;EAEH,UAAA,EAjDI,IAiDJ;EACE,SAAA,CAAA,EAAA,MAAA;EAMI,aAAA,CAAA,EAAA,MAAA;EACH,QAAA,EAtDD,kBAsDC,EAAA;;AAII,UAvDA,iBAAA,CAuDe;EAQf,KAAA,EAAA,MAAA;EAKA,UAAA,EAAA,MAAA;EACI,MAAA,CAAA,EAAA,MAAA;;AACU,UAhEd,aAAA,CAgEc;EAAR,EAAA,EAAA,MAAA;EAGX,IAAA,EAAA,oBAAA,GAAA,aAAA,GAAA,mBAAA,GAAA,gBAAA,GAAA,iBAAA,GAAA,iBAAA;EACoD,WAAA,EAAA,MAAA;EAC3D,SAAA,CAAA,EA3DS,mBA2DT;EACY,UAAA,EA3DH,iBA2DG;EAAgC,QAAA,CAAA,EA1DpC,MA0DoC,CAAA,MAAA,EAAA,OAAA,CAAA;EAAR,QAAA,EAzD7B,kBAyD6B,EAAA;;AAGxB,UAzDA,sBAAA,CA0DG;EAGH,OAAA,EAAA,MAAA;;;SAzDR;SACA,cACL,gBACA,iBAAiB;;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,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contractspec/lib.evolution",
|
|
3
|
+
"version": "1.44.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
14
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
15
|
+
"build": "bun build:types && bun build:bundle",
|
|
16
|
+
"build:bundle": "tsdown",
|
|
17
|
+
"build:types": "tsc --noEmit",
|
|
18
|
+
"dev": "bun build:bundle --watch",
|
|
19
|
+
"clean": "rimraf dist .turbo",
|
|
20
|
+
"lint": "bun lint:fix",
|
|
21
|
+
"lint:fix": "eslint src --fix",
|
|
22
|
+
"lint:check": "eslint src",
|
|
23
|
+
"test": "bun test"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"ai": "6.0.3",
|
|
27
|
+
"zod": "^4.1.13",
|
|
28
|
+
"@contractspec/lib.ai-agent": "1.44.0",
|
|
29
|
+
"@contractspec/lib.contracts": "1.44.0",
|
|
30
|
+
"@contractspec/lib.lifecycle": "1.44.0",
|
|
31
|
+
"@contractspec/lib.observability": "1.44.0",
|
|
32
|
+
"@contractspec/lib.schema": "1.44.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@prisma/client": "7.2.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@contractspec/tool.tsdown": "1.44.0",
|
|
39
|
+
"@contractspec/tool.typescript": "1.44.0",
|
|
40
|
+
"tsdown": "^0.18.3",
|
|
41
|
+
"typescript": "^5.9.3"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": "./dist/index.js",
|
|
45
|
+
"./*": "./*"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"exports": {
|
|
50
|
+
".": "./dist/index.js",
|
|
51
|
+
"./*": "./*"
|
|
52
|
+
},
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
},
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
59
|
+
"directory": "packages/libs/evolution"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://contractspec.io"
|
|
62
|
+
}
|