@sovr/engine 3.6.0 → 3.7.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/dist/index.d.mts +340 -8
- package/dist/index.d.ts +340 -8
- package/dist/index.js +56 -0
- package/dist/index.mjs +55 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -845,14 +845,14 @@ interface CostRecord {
|
|
|
845
845
|
tokenCount?: number;
|
|
846
846
|
modelName?: string;
|
|
847
847
|
timestamp: number;
|
|
848
|
-
category: CostCategory;
|
|
848
|
+
category: CostCategory$1;
|
|
849
849
|
metadata?: Record<string, unknown>;
|
|
850
850
|
}
|
|
851
|
-
type CostCategory = 'llm_inference' | 'tool_call' | 'human_review' | 'storage' | 'network' | 'compute' | 'other';
|
|
851
|
+
type CostCategory$1 = 'llm_inference' | 'tool_call' | 'human_review' | 'storage' | 'network' | 'compute' | 'other';
|
|
852
852
|
interface CostSummary {
|
|
853
853
|
period: '1h' | '24h' | '7d' | '30d';
|
|
854
854
|
totalCostUsd: number;
|
|
855
|
-
byCategory: Record<CostCategory, number>;
|
|
855
|
+
byCategory: Record<CostCategory$1, number>;
|
|
856
856
|
byAgent: Record<string, number>;
|
|
857
857
|
byTool: Record<string, number>;
|
|
858
858
|
recordCount: number;
|
|
@@ -864,7 +864,7 @@ interface CostSummary {
|
|
|
864
864
|
interface DailyCostStats {
|
|
865
865
|
date: string;
|
|
866
866
|
totalCostUsd: number;
|
|
867
|
-
byCategory: Record<CostCategory, number>;
|
|
867
|
+
byCategory: Record<CostCategory$1, number>;
|
|
868
868
|
actionCount: number;
|
|
869
869
|
uniqueAgents: number;
|
|
870
870
|
budgetUtilization: number;
|
|
@@ -1886,7 +1886,7 @@ declare class ContextAccelerator {
|
|
|
1886
1886
|
* - 告警事件持久化: 写入 sovr_system_events
|
|
1887
1887
|
* - DegradeEvaluator Cron: 定时评估趋势
|
|
1888
1888
|
*/
|
|
1889
|
-
type AlertSeverity = 'INFO' | 'WARN' | 'CRITICAL' | 'EMERGENCY';
|
|
1889
|
+
type AlertSeverity$1 = 'INFO' | 'WARN' | 'CRITICAL' | 'EMERGENCY';
|
|
1890
1890
|
type AlertType = 'BLOCK_RATE_SURGE' | 'OVERRIDE_RATE_SURGE' | 'UNKNOWN_REASON_CODE' | 'APPROVAL_QUEUE_BACKLOG' | 'CONFIDENCE_DROP' | 'LATENCY_SPIKE' | 'ERROR_RATE_SURGE';
|
|
1891
1891
|
type ProtectiveAction = 'DEGRADE' | 'TIGHTEN_THRESHOLD' | 'KILL_SWITCH' | 'NOTIFY_ONLY' | 'FORCE_HUMAN_GATE';
|
|
1892
1892
|
interface AlertThreshold {
|
|
@@ -1895,7 +1895,7 @@ interface AlertThreshold {
|
|
|
1895
1895
|
baseline_window_hours: number;
|
|
1896
1896
|
surge_multiplier: number;
|
|
1897
1897
|
absolute_threshold: number;
|
|
1898
|
-
severity: AlertSeverity;
|
|
1898
|
+
severity: AlertSeverity$1;
|
|
1899
1899
|
protective_actions: ProtectiveAction[];
|
|
1900
1900
|
cooldown_seconds: number;
|
|
1901
1901
|
enabled: boolean;
|
|
@@ -1911,7 +1911,7 @@ interface TrendMetric {
|
|
|
1911
1911
|
interface AlertEvent {
|
|
1912
1912
|
alert_id: string;
|
|
1913
1913
|
alert_type: AlertType;
|
|
1914
|
-
severity: AlertSeverity;
|
|
1914
|
+
severity: AlertSeverity$1;
|
|
1915
1915
|
metric_name: string;
|
|
1916
1916
|
current_value: number;
|
|
1917
1917
|
baseline_value: number;
|
|
@@ -2283,6 +2283,338 @@ declare class OverrideDriftAnalyzer {
|
|
|
2283
2283
|
};
|
|
2284
2284
|
}
|
|
2285
2285
|
|
|
2286
|
+
/**
|
|
2287
|
+
* cockpitDataService.ts — SOVR Cockpit 控制面板数据服务层
|
|
2288
|
+
*
|
|
2289
|
+
* 来源文档: SOVR系统Cockpit趋势面板执行方案.pdf 等 85 份文档
|
|
2290
|
+
* 优先级: P0
|
|
2291
|
+
*
|
|
2292
|
+
* 职责:
|
|
2293
|
+
* 1. 聚合多维度运行指标 (gate/audit/trust/budget)
|
|
2294
|
+
* 2. 提供 Cockpit 面板所需的实时数据 API
|
|
2295
|
+
* 3. 趋势计算 + 健康评分 + 异常标记
|
|
2296
|
+
* 4. 支持时间窗口查询 (1h/6h/24h/7d/30d)
|
|
2297
|
+
*/
|
|
2298
|
+
interface CockpitTimeWindow {
|
|
2299
|
+
label: string;
|
|
2300
|
+
seconds: number;
|
|
2301
|
+
}
|
|
2302
|
+
declare const TIME_WINDOWS: Record<string, CockpitTimeWindow>;
|
|
2303
|
+
interface MetricPoint {
|
|
2304
|
+
timestamp: number;
|
|
2305
|
+
value: number;
|
|
2306
|
+
label?: string;
|
|
2307
|
+
}
|
|
2308
|
+
interface CockpitMetric {
|
|
2309
|
+
id: string;
|
|
2310
|
+
name: string;
|
|
2311
|
+
category: 'gate' | 'audit' | 'trust' | 'budget' | 'performance' | 'security';
|
|
2312
|
+
current: number;
|
|
2313
|
+
previous: number;
|
|
2314
|
+
trend: 'up' | 'down' | 'stable';
|
|
2315
|
+
changePercent: number;
|
|
2316
|
+
unit: string;
|
|
2317
|
+
isAnomaly: boolean;
|
|
2318
|
+
history: MetricPoint[];
|
|
2319
|
+
}
|
|
2320
|
+
interface HealthScore {
|
|
2321
|
+
overall: number;
|
|
2322
|
+
gate: number;
|
|
2323
|
+
audit: number;
|
|
2324
|
+
trust: number;
|
|
2325
|
+
budget: number;
|
|
2326
|
+
security: number;
|
|
2327
|
+
lastUpdated: number;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* timeConsistencyService.ts — SOVR 时间一致性服务
|
|
2332
|
+
*
|
|
2333
|
+
* 来源文档: 时间一致性实施方案.pdf 等 62 份文档
|
|
2334
|
+
* 优先级: P0
|
|
2335
|
+
*
|
|
2336
|
+
* 职责:
|
|
2337
|
+
* 1. 统一时间戳格式 (UTC Unix ms)
|
|
2338
|
+
* 2. 时钟偏移检测 + 校正
|
|
2339
|
+
* 3. 事件排序一致性保证
|
|
2340
|
+
* 4. 跨服务时间同步验证
|
|
2341
|
+
*/
|
|
2342
|
+
interface TimestampRecord {
|
|
2343
|
+
utcMs: number;
|
|
2344
|
+
iso8601: string;
|
|
2345
|
+
source: string;
|
|
2346
|
+
clockDriftMs: number;
|
|
2347
|
+
isReliable: boolean;
|
|
2348
|
+
}
|
|
2349
|
+
interface ClockDriftReport {
|
|
2350
|
+
sourceA: string;
|
|
2351
|
+
sourceB: string;
|
|
2352
|
+
driftMs: number;
|
|
2353
|
+
measuredAt: number;
|
|
2354
|
+
withinTolerance: boolean;
|
|
2355
|
+
}
|
|
2356
|
+
interface EventOrderValidation {
|
|
2357
|
+
events: Array<{
|
|
2358
|
+
id: string;
|
|
2359
|
+
timestamp: number;
|
|
2360
|
+
}>;
|
|
2361
|
+
isMonotonic: boolean;
|
|
2362
|
+
violations: Array<{
|
|
2363
|
+
before: string;
|
|
2364
|
+
after: string;
|
|
2365
|
+
gapMs: number;
|
|
2366
|
+
}>;
|
|
2367
|
+
}
|
|
2368
|
+
interface TimeConsistencyConfig {
|
|
2369
|
+
maxClockDriftMs: number;
|
|
2370
|
+
ntpCheckIntervalMs: number;
|
|
2371
|
+
enableDriftCorrection: boolean;
|
|
2372
|
+
referenceSource: string;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* failureAbsorber.ts — SOVR 失败吸收机制
|
|
2377
|
+
*
|
|
2378
|
+
* 来源文档: 失败吸收机制执行计划.pdf + 失败资本化自动回灌方案.pdf (20 份文档)
|
|
2379
|
+
* 优先级: P0
|
|
2380
|
+
*
|
|
2381
|
+
* 职责:
|
|
2382
|
+
* 1. 失败分类 (transient/permanent/degraded)
|
|
2383
|
+
* 2. 失败资本化 — 将失败转化为知识资产
|
|
2384
|
+
* 3. 自动回灌 — 失败经验注入策略引擎
|
|
2385
|
+
* 4. 失败预算 — 控制可接受失败率
|
|
2386
|
+
*/
|
|
2387
|
+
type FailureCategory = 'transient' | 'permanent' | 'degraded' | 'unknown';
|
|
2388
|
+
type FailureSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
2389
|
+
interface FailureRecord {
|
|
2390
|
+
id: string;
|
|
2391
|
+
timestamp: number;
|
|
2392
|
+
category: FailureCategory;
|
|
2393
|
+
severity: FailureSeverity;
|
|
2394
|
+
source: string;
|
|
2395
|
+
action: string;
|
|
2396
|
+
error: string;
|
|
2397
|
+
context: Record<string, unknown>;
|
|
2398
|
+
retryCount: number;
|
|
2399
|
+
maxRetries: number;
|
|
2400
|
+
resolved: boolean;
|
|
2401
|
+
capitalizedAs?: string;
|
|
2402
|
+
injectedToPolicy: boolean;
|
|
2403
|
+
}
|
|
2404
|
+
interface FailureBudget {
|
|
2405
|
+
windowMs: number;
|
|
2406
|
+
maxFailures: number;
|
|
2407
|
+
currentFailures: number;
|
|
2408
|
+
exhausted: boolean;
|
|
2409
|
+
resetAt: number;
|
|
2410
|
+
}
|
|
2411
|
+
interface CapitalizationResult {
|
|
2412
|
+
failureId: string;
|
|
2413
|
+
knowledgeType: 'pattern' | 'rule' | 'threshold' | 'blocklist';
|
|
2414
|
+
description: string;
|
|
2415
|
+
injectedAt: number;
|
|
2416
|
+
policyRef?: string;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* realityAnchor.ts — SOVR 现实约束锚定系统
|
|
2421
|
+
*
|
|
2422
|
+
* 来源文档: 现实约束锚定系统执行计划.pdf (19 份文档)
|
|
2423
|
+
* 优先级: P0
|
|
2424
|
+
*
|
|
2425
|
+
* 职责:
|
|
2426
|
+
* 1. 物理世界约束注入 (时间/预算/法规/物理限制)
|
|
2427
|
+
* 2. AI 输出的现实可行性验证
|
|
2428
|
+
* 3. 约束冲突检测 + 解决建议
|
|
2429
|
+
* 4. 约束松弛度评估
|
|
2430
|
+
*/
|
|
2431
|
+
type ConstraintType = 'temporal' | 'financial' | 'legal' | 'physical' | 'capacity' | 'dependency';
|
|
2432
|
+
type ConstraintStatus = 'active' | 'violated' | 'relaxed' | 'expired';
|
|
2433
|
+
interface RealityConstraint {
|
|
2434
|
+
id: string;
|
|
2435
|
+
type: ConstraintType;
|
|
2436
|
+
name: string;
|
|
2437
|
+
description: string;
|
|
2438
|
+
condition: string;
|
|
2439
|
+
threshold: number | string;
|
|
2440
|
+
currentValue?: number | string;
|
|
2441
|
+
status: ConstraintStatus;
|
|
2442
|
+
severity: 'hard' | 'soft';
|
|
2443
|
+
createdAt: number;
|
|
2444
|
+
expiresAt?: number;
|
|
2445
|
+
metadata: Record<string, unknown>;
|
|
2446
|
+
}
|
|
2447
|
+
interface FeasibilityCheck {
|
|
2448
|
+
actionId: string;
|
|
2449
|
+
action: string;
|
|
2450
|
+
constraints: ConstraintCheckResult[];
|
|
2451
|
+
overallFeasible: boolean;
|
|
2452
|
+
feasibilityScore: number;
|
|
2453
|
+
suggestions: string[];
|
|
2454
|
+
}
|
|
2455
|
+
interface ConstraintCheckResult {
|
|
2456
|
+
constraintId: string;
|
|
2457
|
+
constraintName: string;
|
|
2458
|
+
type: ConstraintType;
|
|
2459
|
+
passed: boolean;
|
|
2460
|
+
reason: string;
|
|
2461
|
+
relaxable: boolean;
|
|
2462
|
+
relaxationCost?: string;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
/**
|
|
2466
|
+
* topNRanker.ts — SOVR Top-N 排名引擎
|
|
2467
|
+
*
|
|
2468
|
+
* 来源文档: 人工智能痛点Top-N实现方案.pdf (14 份文档)
|
|
2469
|
+
* 优先级: P0
|
|
2470
|
+
*
|
|
2471
|
+
* 职责:
|
|
2472
|
+
* 1. 多维度评分排名 (风险/频率/影响/成本)
|
|
2473
|
+
* 2. 动态 Top-N 列表维护
|
|
2474
|
+
* 3. 排名变化追踪 + 趋势告警
|
|
2475
|
+
* 4. 可配置权重 + 自定义评分函数
|
|
2476
|
+
*/
|
|
2477
|
+
interface RankableItem {
|
|
2478
|
+
id: string;
|
|
2479
|
+
name: string;
|
|
2480
|
+
category: string;
|
|
2481
|
+
dimensions: Record<string, number>;
|
|
2482
|
+
metadata?: Record<string, unknown>;
|
|
2483
|
+
}
|
|
2484
|
+
interface RankResult {
|
|
2485
|
+
rank: number;
|
|
2486
|
+
item: RankableItem;
|
|
2487
|
+
compositeScore: number;
|
|
2488
|
+
dimensionScores: Record<string, number>;
|
|
2489
|
+
previousRank?: number;
|
|
2490
|
+
rankChange: number;
|
|
2491
|
+
}
|
|
2492
|
+
interface RankingConfig {
|
|
2493
|
+
n: number;
|
|
2494
|
+
weights: Record<string, number>;
|
|
2495
|
+
sortOrder: 'desc' | 'asc';
|
|
2496
|
+
minScoreThreshold: number;
|
|
2497
|
+
trackHistory: boolean;
|
|
2498
|
+
}
|
|
2499
|
+
interface RankingSnapshot {
|
|
2500
|
+
timestamp: number;
|
|
2501
|
+
configHash: string;
|
|
2502
|
+
rankings: RankResult[];
|
|
2503
|
+
totalItems: number;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
/**
|
|
2507
|
+
* finOpsRiskEngine.ts — SOVR FinOps 风险引擎
|
|
2508
|
+
*
|
|
2509
|
+
* 来源文档: FinOps风险执行方案.pdf (3 份文档)
|
|
2510
|
+
* 优先级: P1
|
|
2511
|
+
*
|
|
2512
|
+
* 职责:
|
|
2513
|
+
* 1. AI 运营成本追踪 (LLM tokens, API 调用, 存储)
|
|
2514
|
+
* 2. 预算阈值告警
|
|
2515
|
+
* 3. 成本异常检测
|
|
2516
|
+
* 4. 成本优化建议
|
|
2517
|
+
* 5. FinOps 报告生成
|
|
2518
|
+
*/
|
|
2519
|
+
type CostCategory = 'llm_tokens' | 'api_calls' | 'storage' | 'compute' | 'bandwidth' | 'third_party' | 'other';
|
|
2520
|
+
type AlertSeverity = 'info' | 'warning' | 'critical';
|
|
2521
|
+
interface CostEntry {
|
|
2522
|
+
id: string;
|
|
2523
|
+
category: CostCategory;
|
|
2524
|
+
service: string;
|
|
2525
|
+
amount: number;
|
|
2526
|
+
quantity: number;
|
|
2527
|
+
unitPrice: number;
|
|
2528
|
+
timestamp: number;
|
|
2529
|
+
metadata: Record<string, unknown>;
|
|
2530
|
+
}
|
|
2531
|
+
interface BudgetConfig {
|
|
2532
|
+
category: CostCategory;
|
|
2533
|
+
dailyLimit: number;
|
|
2534
|
+
monthlyLimit: number;
|
|
2535
|
+
alertThresholds: number[];
|
|
2536
|
+
}
|
|
2537
|
+
interface CostAlert {
|
|
2538
|
+
id: string;
|
|
2539
|
+
category: CostCategory;
|
|
2540
|
+
severity: AlertSeverity;
|
|
2541
|
+
message: string;
|
|
2542
|
+
currentSpend: number;
|
|
2543
|
+
budgetLimit: number;
|
|
2544
|
+
percentage: number;
|
|
2545
|
+
timestamp: number;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
/**
|
|
2549
|
+
* apiCacheOptimizer.ts — SOVR API 缓存优化策略引擎
|
|
2550
|
+
*
|
|
2551
|
+
* 来源文档: SOVRAPI缓存优化策略.pdf (2 份文档)
|
|
2552
|
+
* 优先级: P1
|
|
2553
|
+
*
|
|
2554
|
+
* 职责:
|
|
2555
|
+
* 1. 多层缓存管理 (L1 内存 / L2 Redis / L3 CDN)
|
|
2556
|
+
* 2. 缓存策略自动选择 (TTL / LRU / LFU / Write-Through)
|
|
2557
|
+
* 3. 缓存命中率监控与优化
|
|
2558
|
+
* 4. 缓存预热与失效管理
|
|
2559
|
+
* 5. 热点检测与自动扩容
|
|
2560
|
+
*/
|
|
2561
|
+
type CacheLayer = 'L1_memory' | 'L2_redis' | 'L3_cdn';
|
|
2562
|
+
type CacheStrategy = 'ttl' | 'lru' | 'lfu' | 'write_through' | 'write_behind' | 'read_through';
|
|
2563
|
+
type EvictionPolicy = 'lru' | 'lfu' | 'fifo' | 'random' | 'ttl';
|
|
2564
|
+
interface CacheConfig {
|
|
2565
|
+
layer: CacheLayer;
|
|
2566
|
+
maxSize: number;
|
|
2567
|
+
maxMemoryMB: number;
|
|
2568
|
+
defaultTTLMs: number;
|
|
2569
|
+
evictionPolicy: EvictionPolicy;
|
|
2570
|
+
warmupEnabled: boolean;
|
|
2571
|
+
compressionEnabled: boolean;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* releaseManager.ts — SOVR 冻结发布管理器
|
|
2576
|
+
*
|
|
2577
|
+
* 来源文档: 主权AIv1.2冻结发布方案.pdf + SOVRv2.0最终阶段计划.pdf + SOVRv2.0Gamma自动化执行计划.pdf (4 份文档)
|
|
2578
|
+
* 优先级: P1
|
|
2579
|
+
*
|
|
2580
|
+
* 职责:
|
|
2581
|
+
* 1. 版本冻结管理 (Code Freeze / Feature Freeze)
|
|
2582
|
+
* 2. 发布 Checklist 自动化
|
|
2583
|
+
* 3. 回归测试协调
|
|
2584
|
+
* 4. 发布门禁 (Release Gate)
|
|
2585
|
+
* 5. 灰度发布与回滚管理
|
|
2586
|
+
*/
|
|
2587
|
+
type FreezeType = 'feature_freeze' | 'code_freeze' | 'full_freeze';
|
|
2588
|
+
type ReleasePhase = 'planning' | 'development' | 'feature_frozen' | 'code_frozen' | 'testing' | 'staging' | 'canary' | 'rolling' | 'released' | 'rolled_back';
|
|
2589
|
+
type ChecklistItemStatus = 'pending' | 'in_progress' | 'passed' | 'failed' | 'skipped' | 'blocked';
|
|
2590
|
+
interface ReleaseVersion {
|
|
2591
|
+
id: string;
|
|
2592
|
+
version: string;
|
|
2593
|
+
codename: string;
|
|
2594
|
+
phase: ReleasePhase;
|
|
2595
|
+
freezeType?: FreezeType;
|
|
2596
|
+
frozenAt?: number;
|
|
2597
|
+
plannedDate: number;
|
|
2598
|
+
actualDate?: number;
|
|
2599
|
+
owner: string;
|
|
2600
|
+
changelog: string[];
|
|
2601
|
+
blockers: string[];
|
|
2602
|
+
rollbackPlan: string;
|
|
2603
|
+
metadata: Record<string, unknown>;
|
|
2604
|
+
}
|
|
2605
|
+
interface ChecklistItem {
|
|
2606
|
+
id: string;
|
|
2607
|
+
releaseId: string;
|
|
2608
|
+
category: 'build' | 'test' | 'security' | 'performance' | 'docs' | 'infra' | 'approval';
|
|
2609
|
+
name: string;
|
|
2610
|
+
description: string;
|
|
2611
|
+
status: ChecklistItemStatus;
|
|
2612
|
+
assignee: string;
|
|
2613
|
+
completedAt?: number;
|
|
2614
|
+
evidence?: string;
|
|
2615
|
+
required: boolean;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2286
2618
|
/**
|
|
2287
2619
|
* @sovr/engine — Unified Policy Engine
|
|
2288
2620
|
*
|
|
@@ -2499,4 +2831,4 @@ declare class PolicyEngine {
|
|
|
2499
2831
|
}): void;
|
|
2500
2832
|
}
|
|
2501
2833
|
|
|
2502
|
-
export { type ABTestConfig, AdaptiveThresholdManager, type AdaptiveThresholdOptions, type AdjustmentResult, type AggregateSnapshot, type AggregationResult, type AggregationType, type AggregationWindow, type AlertEvent, type AlertSeverity, type AlertThreshold, type AlertType, type AssembledContext, type AttributionRule, type AuditEvent, AutoHardenEngine, type BudgetAlert, type BudgetLevel, type BudgetNode, type CacheEntry, type CapabilityFlags, type Channel, type CircuitBreakerState, type CircuitState, type ComparableInput, type ComparableResult, type ComparisonNode, type CompiledExpression, type ConsistencyMismatch, type ConsistencyResult, type ConstraintConfig, type ConstraintDecision, type ConstraintLevel, type ConstraintMode, type ConstraintState, type ConstraintTrigger, ContextAccelerator, type ContextAcceleratorConfig, type ContextFragment, type ContextPriority, type ContributionDimension, type ContributionEvent, type ContributionScore, ContributionSettlementEngine, type CostAuditEvent, type CostCategory, type CostEstimate, type CostEstimateRequest, type CostGateEnhancedConfig, CostGateEnhancedEngine, type CostRecord, type CostReport, type CostSummary, type DCFInput, type DCFResult, DEFAULT_CA_CONFIG, DEFAULT_GE_CONFIG, DEFAULT_HARD_RULES, DEFAULT_RULES, DEFAULT_SCORING_WEIGHTS, DEFAULT_TSA_CONFIG, type DataPoint, type DecisionFeedback, type DegradationLevel, type DegradeState, type DriftAlert, type DriftAnalyzerConfig, type DriftConfig, type DriftIndex, type DriftPattern, type DriftResult, type DriftWindow, type EligibilityResult, type EngineConfig, type EngineTier, type EngineTierLimits, type EntityType, type EstimateAccuracy, type EvalContext, type EvalRequest, type EvalResult, EvolutionChannelEngine, type EvolutionConfig, type EvolutionEvent, type ExecContext, type ExprTreePolicyRule, type ExpressionNode, type FeatureSwitchDef, type FeatureSwitchState, FeatureSwitchesManager, type FeatureSwitchesOptions, type FunctionNode, type PolicyVersion as GovPolicyVersion, type GovernanceDecision, GovernanceEnhancer, type GovernanceEnhancerConfig, type GovernanceRule, type HardRule, type HardenConfig, type HardenEvent, type HardenLevel, type HardenMeasure, type HardenMeasureType, type HardenState, type HttpContext, type KillSwitchState, type LiteralNode, type LogicalNode, type MarketSize, type McpContext, type ModelCandidate, type ModelPricing, type ModelTier, type MonitoringMetrics, type MultiLevelBudgetConfig, MultiLevelBudgetEngine, type NetworkEffectInput, type NetworkEffectResult, type NotNode, OverrideDriftAnalyzer, type OverrideEvent, type PenaltyCheck, PolicyEngine, type PolicyRule, type PolicySnapshot, type PolicyVersion$1 as PolicyVersion, type PrefetchRule, type PricingEvalRequest, type PricingEvalResult, type PricingRule, PricingRulesEngine, type ProtectiveAction, type ReasonCode, type RecalcEngineConfig, type RecalcGranularity, type RecalcHandler, type RecalcTask, type RecalcTaskStatus, type RecalcTriggerType, RecalculationEngine, type RiskLevel, type RoutingDecision, type RoutingRequest, type RuleCondition, type RuleEvalResult, SOVR_FEATURE_SWITCHES, type ScoreConfigVersion, type ScoringResult, type ScoringWeights, SelfConstraintEngine, SemanticDriftDetectorEngine, type SemanticFingerprint, type SensitivityResult, type SettlementContext, type SqlContext, type SystemState, type ThresholdConfig, type TighteningThresholds, TimeSeriesAggregator, type TimeSeriesAggregatorConfig, type ToolPricing, TrendAlertEngine, type TrendMetric, TwoPhaseRouter, type TwoPhaseRouterConfig, type UnitEconomics, ValuationModel, type ValuationModelConfig, type VariableNode, type Verdict, type WindowType, compileFromJSON, compileRuleSet, createAutoHardenEngine, createCostGateEnhanced, createEvolutionChannel, createMultiLevelBudget, createRecalculationEngine, createSemanticDriftDetector, PolicyEngine as default, estimateCost, evaluateRules, getAccuracyStats, getModelPricingTable, getToolPricingTable, recordActualCost, registerFunction, updateModelPricing, updateToolPricing };
|
|
2834
|
+
export { type ABTestConfig, AdaptiveThresholdManager, type AdaptiveThresholdOptions, type AdjustmentResult, type AggregateSnapshot, type AggregationResult, type AggregationType, type AggregationWindow, type AlertEvent, type AlertSeverity$1 as AlertSeverity, type AlertThreshold, type AlertType, type AssembledContext, type AttributionRule, type AuditEvent, AutoHardenEngine, type BudgetAlert, type BudgetConfig, type BudgetLevel, type BudgetNode, type CacheConfig, type CacheEntry, type CacheLayer, type CacheStrategy, type CapabilityFlags, type CapitalizationResult, type Channel, type ChecklistItem, type ChecklistItemStatus, type CircuitBreakerState, type CircuitState, type ClockDriftReport, type CockpitMetric, type CockpitTimeWindow, type ComparableInput, type ComparableResult, type ComparisonNode, type CompiledExpression, type ConsistencyMismatch, type ConsistencyResult, type ConstraintCheckResult, type ConstraintConfig, type ConstraintDecision, type ConstraintLevel, type ConstraintMode, type ConstraintState, type ConstraintTrigger, ContextAccelerator, type ContextAcceleratorConfig, type ContextFragment, type ContextPriority, type ContributionDimension, type ContributionEvent, type ContributionScore, ContributionSettlementEngine, type CostAlert, type CostAuditEvent, type CostCategory$1 as CostCategory, type CostEntry, type CostEstimate, type CostEstimateRequest, type CostGateEnhancedConfig, CostGateEnhancedEngine, type CostRecord, type CostReport, type CostSummary, type DCFInput, type DCFResult, DEFAULT_CA_CONFIG, DEFAULT_GE_CONFIG, DEFAULT_HARD_RULES, DEFAULT_RULES, DEFAULT_SCORING_WEIGHTS, DEFAULT_TSA_CONFIG, type DataPoint, type DecisionFeedback, type DegradationLevel, type DegradeState, type DriftAlert, type DriftAnalyzerConfig, type DriftConfig, type DriftIndex, type DriftPattern, type DriftResult, type DriftWindow, type EligibilityResult, type EngineConfig, type EngineTier, type EngineTierLimits, type EntityType, type EstimateAccuracy, type EvalContext, type EvalRequest, type EvalResult, type EventOrderValidation, type EvictionPolicy, EvolutionChannelEngine, type EvolutionConfig, type EvolutionEvent, type ExecContext, type ExprTreePolicyRule, type ExpressionNode, type FailureBudget, type FailureCategory, type FailureRecord, type FailureSeverity, type FeasibilityCheck, type FeatureSwitchDef, type FeatureSwitchState, FeatureSwitchesManager, type FeatureSwitchesOptions, type CostCategory as FinOpsCostCategory, type FreezeType, type FunctionNode, type PolicyVersion as GovPolicyVersion, type GovernanceDecision, GovernanceEnhancer, type GovernanceEnhancerConfig, type GovernanceRule, type HardRule, type HardenConfig, type HardenEvent, type HardenLevel, type HardenMeasure, type HardenMeasureType, type HardenState, type HealthScore, type HttpContext, type KillSwitchState, type LiteralNode, type LogicalNode, type MarketSize, type McpContext, type MetricPoint, type ModelCandidate, type ModelPricing, type ModelTier, type MonitoringMetrics, type MultiLevelBudgetConfig, MultiLevelBudgetEngine, type NetworkEffectInput, type NetworkEffectResult, type NotNode, OverrideDriftAnalyzer, type OverrideEvent, type PenaltyCheck, PolicyEngine, type PolicyRule, type PolicySnapshot, type PolicyVersion$1 as PolicyVersion, type PrefetchRule, type PricingEvalRequest, type PricingEvalResult, type PricingRule, PricingRulesEngine, type ProtectiveAction, type RankResult, type RankableItem, type RankingConfig, type RankingSnapshot, type RealityConstraint, type ReasonCode, type RecalcEngineConfig, type RecalcGranularity, type RecalcHandler, type RecalcTask, type RecalcTaskStatus, type RecalcTriggerType, RecalculationEngine, type ReleasePhase, type ReleaseVersion, type RiskLevel, type RoutingDecision, type RoutingRequest, type RuleCondition, type RuleEvalResult, SOVR_FEATURE_SWITCHES, type ScoreConfigVersion, type ScoringResult, type ScoringWeights, SelfConstraintEngine, SemanticDriftDetectorEngine, type SemanticFingerprint, type SensitivityResult, type SettlementContext, type SqlContext, type SystemState, TIME_WINDOWS, type ThresholdConfig, type TighteningThresholds, type TimeConsistencyConfig, TimeSeriesAggregator, type TimeSeriesAggregatorConfig, type TimestampRecord, type ToolPricing, TrendAlertEngine, type TrendMetric, TwoPhaseRouter, type TwoPhaseRouterConfig, type UnitEconomics, ValuationModel, type ValuationModelConfig, type VariableNode, type Verdict, type WindowType, compileFromJSON, compileRuleSet, createAutoHardenEngine, createCostGateEnhanced, createEvolutionChannel, createMultiLevelBudget, createRecalculationEngine, createSemanticDriftDetector, PolicyEngine as default, estimateCost, evaluateRules, getAccuracyStats, getModelPricingTable, getToolPricingTable, recordActualCost, registerFunction, updateModelPricing, updateToolPricing };
|
package/dist/index.d.ts
CHANGED
|
@@ -845,14 +845,14 @@ interface CostRecord {
|
|
|
845
845
|
tokenCount?: number;
|
|
846
846
|
modelName?: string;
|
|
847
847
|
timestamp: number;
|
|
848
|
-
category: CostCategory;
|
|
848
|
+
category: CostCategory$1;
|
|
849
849
|
metadata?: Record<string, unknown>;
|
|
850
850
|
}
|
|
851
|
-
type CostCategory = 'llm_inference' | 'tool_call' | 'human_review' | 'storage' | 'network' | 'compute' | 'other';
|
|
851
|
+
type CostCategory$1 = 'llm_inference' | 'tool_call' | 'human_review' | 'storage' | 'network' | 'compute' | 'other';
|
|
852
852
|
interface CostSummary {
|
|
853
853
|
period: '1h' | '24h' | '7d' | '30d';
|
|
854
854
|
totalCostUsd: number;
|
|
855
|
-
byCategory: Record<CostCategory, number>;
|
|
855
|
+
byCategory: Record<CostCategory$1, number>;
|
|
856
856
|
byAgent: Record<string, number>;
|
|
857
857
|
byTool: Record<string, number>;
|
|
858
858
|
recordCount: number;
|
|
@@ -864,7 +864,7 @@ interface CostSummary {
|
|
|
864
864
|
interface DailyCostStats {
|
|
865
865
|
date: string;
|
|
866
866
|
totalCostUsd: number;
|
|
867
|
-
byCategory: Record<CostCategory, number>;
|
|
867
|
+
byCategory: Record<CostCategory$1, number>;
|
|
868
868
|
actionCount: number;
|
|
869
869
|
uniqueAgents: number;
|
|
870
870
|
budgetUtilization: number;
|
|
@@ -1886,7 +1886,7 @@ declare class ContextAccelerator {
|
|
|
1886
1886
|
* - 告警事件持久化: 写入 sovr_system_events
|
|
1887
1887
|
* - DegradeEvaluator Cron: 定时评估趋势
|
|
1888
1888
|
*/
|
|
1889
|
-
type AlertSeverity = 'INFO' | 'WARN' | 'CRITICAL' | 'EMERGENCY';
|
|
1889
|
+
type AlertSeverity$1 = 'INFO' | 'WARN' | 'CRITICAL' | 'EMERGENCY';
|
|
1890
1890
|
type AlertType = 'BLOCK_RATE_SURGE' | 'OVERRIDE_RATE_SURGE' | 'UNKNOWN_REASON_CODE' | 'APPROVAL_QUEUE_BACKLOG' | 'CONFIDENCE_DROP' | 'LATENCY_SPIKE' | 'ERROR_RATE_SURGE';
|
|
1891
1891
|
type ProtectiveAction = 'DEGRADE' | 'TIGHTEN_THRESHOLD' | 'KILL_SWITCH' | 'NOTIFY_ONLY' | 'FORCE_HUMAN_GATE';
|
|
1892
1892
|
interface AlertThreshold {
|
|
@@ -1895,7 +1895,7 @@ interface AlertThreshold {
|
|
|
1895
1895
|
baseline_window_hours: number;
|
|
1896
1896
|
surge_multiplier: number;
|
|
1897
1897
|
absolute_threshold: number;
|
|
1898
|
-
severity: AlertSeverity;
|
|
1898
|
+
severity: AlertSeverity$1;
|
|
1899
1899
|
protective_actions: ProtectiveAction[];
|
|
1900
1900
|
cooldown_seconds: number;
|
|
1901
1901
|
enabled: boolean;
|
|
@@ -1911,7 +1911,7 @@ interface TrendMetric {
|
|
|
1911
1911
|
interface AlertEvent {
|
|
1912
1912
|
alert_id: string;
|
|
1913
1913
|
alert_type: AlertType;
|
|
1914
|
-
severity: AlertSeverity;
|
|
1914
|
+
severity: AlertSeverity$1;
|
|
1915
1915
|
metric_name: string;
|
|
1916
1916
|
current_value: number;
|
|
1917
1917
|
baseline_value: number;
|
|
@@ -2283,6 +2283,338 @@ declare class OverrideDriftAnalyzer {
|
|
|
2283
2283
|
};
|
|
2284
2284
|
}
|
|
2285
2285
|
|
|
2286
|
+
/**
|
|
2287
|
+
* cockpitDataService.ts — SOVR Cockpit 控制面板数据服务层
|
|
2288
|
+
*
|
|
2289
|
+
* 来源文档: SOVR系统Cockpit趋势面板执行方案.pdf 等 85 份文档
|
|
2290
|
+
* 优先级: P0
|
|
2291
|
+
*
|
|
2292
|
+
* 职责:
|
|
2293
|
+
* 1. 聚合多维度运行指标 (gate/audit/trust/budget)
|
|
2294
|
+
* 2. 提供 Cockpit 面板所需的实时数据 API
|
|
2295
|
+
* 3. 趋势计算 + 健康评分 + 异常标记
|
|
2296
|
+
* 4. 支持时间窗口查询 (1h/6h/24h/7d/30d)
|
|
2297
|
+
*/
|
|
2298
|
+
interface CockpitTimeWindow {
|
|
2299
|
+
label: string;
|
|
2300
|
+
seconds: number;
|
|
2301
|
+
}
|
|
2302
|
+
declare const TIME_WINDOWS: Record<string, CockpitTimeWindow>;
|
|
2303
|
+
interface MetricPoint {
|
|
2304
|
+
timestamp: number;
|
|
2305
|
+
value: number;
|
|
2306
|
+
label?: string;
|
|
2307
|
+
}
|
|
2308
|
+
interface CockpitMetric {
|
|
2309
|
+
id: string;
|
|
2310
|
+
name: string;
|
|
2311
|
+
category: 'gate' | 'audit' | 'trust' | 'budget' | 'performance' | 'security';
|
|
2312
|
+
current: number;
|
|
2313
|
+
previous: number;
|
|
2314
|
+
trend: 'up' | 'down' | 'stable';
|
|
2315
|
+
changePercent: number;
|
|
2316
|
+
unit: string;
|
|
2317
|
+
isAnomaly: boolean;
|
|
2318
|
+
history: MetricPoint[];
|
|
2319
|
+
}
|
|
2320
|
+
interface HealthScore {
|
|
2321
|
+
overall: number;
|
|
2322
|
+
gate: number;
|
|
2323
|
+
audit: number;
|
|
2324
|
+
trust: number;
|
|
2325
|
+
budget: number;
|
|
2326
|
+
security: number;
|
|
2327
|
+
lastUpdated: number;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* timeConsistencyService.ts — SOVR 时间一致性服务
|
|
2332
|
+
*
|
|
2333
|
+
* 来源文档: 时间一致性实施方案.pdf 等 62 份文档
|
|
2334
|
+
* 优先级: P0
|
|
2335
|
+
*
|
|
2336
|
+
* 职责:
|
|
2337
|
+
* 1. 统一时间戳格式 (UTC Unix ms)
|
|
2338
|
+
* 2. 时钟偏移检测 + 校正
|
|
2339
|
+
* 3. 事件排序一致性保证
|
|
2340
|
+
* 4. 跨服务时间同步验证
|
|
2341
|
+
*/
|
|
2342
|
+
interface TimestampRecord {
|
|
2343
|
+
utcMs: number;
|
|
2344
|
+
iso8601: string;
|
|
2345
|
+
source: string;
|
|
2346
|
+
clockDriftMs: number;
|
|
2347
|
+
isReliable: boolean;
|
|
2348
|
+
}
|
|
2349
|
+
interface ClockDriftReport {
|
|
2350
|
+
sourceA: string;
|
|
2351
|
+
sourceB: string;
|
|
2352
|
+
driftMs: number;
|
|
2353
|
+
measuredAt: number;
|
|
2354
|
+
withinTolerance: boolean;
|
|
2355
|
+
}
|
|
2356
|
+
interface EventOrderValidation {
|
|
2357
|
+
events: Array<{
|
|
2358
|
+
id: string;
|
|
2359
|
+
timestamp: number;
|
|
2360
|
+
}>;
|
|
2361
|
+
isMonotonic: boolean;
|
|
2362
|
+
violations: Array<{
|
|
2363
|
+
before: string;
|
|
2364
|
+
after: string;
|
|
2365
|
+
gapMs: number;
|
|
2366
|
+
}>;
|
|
2367
|
+
}
|
|
2368
|
+
interface TimeConsistencyConfig {
|
|
2369
|
+
maxClockDriftMs: number;
|
|
2370
|
+
ntpCheckIntervalMs: number;
|
|
2371
|
+
enableDriftCorrection: boolean;
|
|
2372
|
+
referenceSource: string;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/**
|
|
2376
|
+
* failureAbsorber.ts — SOVR 失败吸收机制
|
|
2377
|
+
*
|
|
2378
|
+
* 来源文档: 失败吸收机制执行计划.pdf + 失败资本化自动回灌方案.pdf (20 份文档)
|
|
2379
|
+
* 优先级: P0
|
|
2380
|
+
*
|
|
2381
|
+
* 职责:
|
|
2382
|
+
* 1. 失败分类 (transient/permanent/degraded)
|
|
2383
|
+
* 2. 失败资本化 — 将失败转化为知识资产
|
|
2384
|
+
* 3. 自动回灌 — 失败经验注入策略引擎
|
|
2385
|
+
* 4. 失败预算 — 控制可接受失败率
|
|
2386
|
+
*/
|
|
2387
|
+
type FailureCategory = 'transient' | 'permanent' | 'degraded' | 'unknown';
|
|
2388
|
+
type FailureSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
2389
|
+
interface FailureRecord {
|
|
2390
|
+
id: string;
|
|
2391
|
+
timestamp: number;
|
|
2392
|
+
category: FailureCategory;
|
|
2393
|
+
severity: FailureSeverity;
|
|
2394
|
+
source: string;
|
|
2395
|
+
action: string;
|
|
2396
|
+
error: string;
|
|
2397
|
+
context: Record<string, unknown>;
|
|
2398
|
+
retryCount: number;
|
|
2399
|
+
maxRetries: number;
|
|
2400
|
+
resolved: boolean;
|
|
2401
|
+
capitalizedAs?: string;
|
|
2402
|
+
injectedToPolicy: boolean;
|
|
2403
|
+
}
|
|
2404
|
+
interface FailureBudget {
|
|
2405
|
+
windowMs: number;
|
|
2406
|
+
maxFailures: number;
|
|
2407
|
+
currentFailures: number;
|
|
2408
|
+
exhausted: boolean;
|
|
2409
|
+
resetAt: number;
|
|
2410
|
+
}
|
|
2411
|
+
interface CapitalizationResult {
|
|
2412
|
+
failureId: string;
|
|
2413
|
+
knowledgeType: 'pattern' | 'rule' | 'threshold' | 'blocklist';
|
|
2414
|
+
description: string;
|
|
2415
|
+
injectedAt: number;
|
|
2416
|
+
policyRef?: string;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* realityAnchor.ts — SOVR 现实约束锚定系统
|
|
2421
|
+
*
|
|
2422
|
+
* 来源文档: 现实约束锚定系统执行计划.pdf (19 份文档)
|
|
2423
|
+
* 优先级: P0
|
|
2424
|
+
*
|
|
2425
|
+
* 职责:
|
|
2426
|
+
* 1. 物理世界约束注入 (时间/预算/法规/物理限制)
|
|
2427
|
+
* 2. AI 输出的现实可行性验证
|
|
2428
|
+
* 3. 约束冲突检测 + 解决建议
|
|
2429
|
+
* 4. 约束松弛度评估
|
|
2430
|
+
*/
|
|
2431
|
+
type ConstraintType = 'temporal' | 'financial' | 'legal' | 'physical' | 'capacity' | 'dependency';
|
|
2432
|
+
type ConstraintStatus = 'active' | 'violated' | 'relaxed' | 'expired';
|
|
2433
|
+
interface RealityConstraint {
|
|
2434
|
+
id: string;
|
|
2435
|
+
type: ConstraintType;
|
|
2436
|
+
name: string;
|
|
2437
|
+
description: string;
|
|
2438
|
+
condition: string;
|
|
2439
|
+
threshold: number | string;
|
|
2440
|
+
currentValue?: number | string;
|
|
2441
|
+
status: ConstraintStatus;
|
|
2442
|
+
severity: 'hard' | 'soft';
|
|
2443
|
+
createdAt: number;
|
|
2444
|
+
expiresAt?: number;
|
|
2445
|
+
metadata: Record<string, unknown>;
|
|
2446
|
+
}
|
|
2447
|
+
interface FeasibilityCheck {
|
|
2448
|
+
actionId: string;
|
|
2449
|
+
action: string;
|
|
2450
|
+
constraints: ConstraintCheckResult[];
|
|
2451
|
+
overallFeasible: boolean;
|
|
2452
|
+
feasibilityScore: number;
|
|
2453
|
+
suggestions: string[];
|
|
2454
|
+
}
|
|
2455
|
+
interface ConstraintCheckResult {
|
|
2456
|
+
constraintId: string;
|
|
2457
|
+
constraintName: string;
|
|
2458
|
+
type: ConstraintType;
|
|
2459
|
+
passed: boolean;
|
|
2460
|
+
reason: string;
|
|
2461
|
+
relaxable: boolean;
|
|
2462
|
+
relaxationCost?: string;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
/**
|
|
2466
|
+
* topNRanker.ts — SOVR Top-N 排名引擎
|
|
2467
|
+
*
|
|
2468
|
+
* 来源文档: 人工智能痛点Top-N实现方案.pdf (14 份文档)
|
|
2469
|
+
* 优先级: P0
|
|
2470
|
+
*
|
|
2471
|
+
* 职责:
|
|
2472
|
+
* 1. 多维度评分排名 (风险/频率/影响/成本)
|
|
2473
|
+
* 2. 动态 Top-N 列表维护
|
|
2474
|
+
* 3. 排名变化追踪 + 趋势告警
|
|
2475
|
+
* 4. 可配置权重 + 自定义评分函数
|
|
2476
|
+
*/
|
|
2477
|
+
interface RankableItem {
|
|
2478
|
+
id: string;
|
|
2479
|
+
name: string;
|
|
2480
|
+
category: string;
|
|
2481
|
+
dimensions: Record<string, number>;
|
|
2482
|
+
metadata?: Record<string, unknown>;
|
|
2483
|
+
}
|
|
2484
|
+
interface RankResult {
|
|
2485
|
+
rank: number;
|
|
2486
|
+
item: RankableItem;
|
|
2487
|
+
compositeScore: number;
|
|
2488
|
+
dimensionScores: Record<string, number>;
|
|
2489
|
+
previousRank?: number;
|
|
2490
|
+
rankChange: number;
|
|
2491
|
+
}
|
|
2492
|
+
interface RankingConfig {
|
|
2493
|
+
n: number;
|
|
2494
|
+
weights: Record<string, number>;
|
|
2495
|
+
sortOrder: 'desc' | 'asc';
|
|
2496
|
+
minScoreThreshold: number;
|
|
2497
|
+
trackHistory: boolean;
|
|
2498
|
+
}
|
|
2499
|
+
interface RankingSnapshot {
|
|
2500
|
+
timestamp: number;
|
|
2501
|
+
configHash: string;
|
|
2502
|
+
rankings: RankResult[];
|
|
2503
|
+
totalItems: number;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
/**
|
|
2507
|
+
* finOpsRiskEngine.ts — SOVR FinOps 风险引擎
|
|
2508
|
+
*
|
|
2509
|
+
* 来源文档: FinOps风险执行方案.pdf (3 份文档)
|
|
2510
|
+
* 优先级: P1
|
|
2511
|
+
*
|
|
2512
|
+
* 职责:
|
|
2513
|
+
* 1. AI 运营成本追踪 (LLM tokens, API 调用, 存储)
|
|
2514
|
+
* 2. 预算阈值告警
|
|
2515
|
+
* 3. 成本异常检测
|
|
2516
|
+
* 4. 成本优化建议
|
|
2517
|
+
* 5. FinOps 报告生成
|
|
2518
|
+
*/
|
|
2519
|
+
type CostCategory = 'llm_tokens' | 'api_calls' | 'storage' | 'compute' | 'bandwidth' | 'third_party' | 'other';
|
|
2520
|
+
type AlertSeverity = 'info' | 'warning' | 'critical';
|
|
2521
|
+
interface CostEntry {
|
|
2522
|
+
id: string;
|
|
2523
|
+
category: CostCategory;
|
|
2524
|
+
service: string;
|
|
2525
|
+
amount: number;
|
|
2526
|
+
quantity: number;
|
|
2527
|
+
unitPrice: number;
|
|
2528
|
+
timestamp: number;
|
|
2529
|
+
metadata: Record<string, unknown>;
|
|
2530
|
+
}
|
|
2531
|
+
interface BudgetConfig {
|
|
2532
|
+
category: CostCategory;
|
|
2533
|
+
dailyLimit: number;
|
|
2534
|
+
monthlyLimit: number;
|
|
2535
|
+
alertThresholds: number[];
|
|
2536
|
+
}
|
|
2537
|
+
interface CostAlert {
|
|
2538
|
+
id: string;
|
|
2539
|
+
category: CostCategory;
|
|
2540
|
+
severity: AlertSeverity;
|
|
2541
|
+
message: string;
|
|
2542
|
+
currentSpend: number;
|
|
2543
|
+
budgetLimit: number;
|
|
2544
|
+
percentage: number;
|
|
2545
|
+
timestamp: number;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
/**
|
|
2549
|
+
* apiCacheOptimizer.ts — SOVR API 缓存优化策略引擎
|
|
2550
|
+
*
|
|
2551
|
+
* 来源文档: SOVRAPI缓存优化策略.pdf (2 份文档)
|
|
2552
|
+
* 优先级: P1
|
|
2553
|
+
*
|
|
2554
|
+
* 职责:
|
|
2555
|
+
* 1. 多层缓存管理 (L1 内存 / L2 Redis / L3 CDN)
|
|
2556
|
+
* 2. 缓存策略自动选择 (TTL / LRU / LFU / Write-Through)
|
|
2557
|
+
* 3. 缓存命中率监控与优化
|
|
2558
|
+
* 4. 缓存预热与失效管理
|
|
2559
|
+
* 5. 热点检测与自动扩容
|
|
2560
|
+
*/
|
|
2561
|
+
type CacheLayer = 'L1_memory' | 'L2_redis' | 'L3_cdn';
|
|
2562
|
+
type CacheStrategy = 'ttl' | 'lru' | 'lfu' | 'write_through' | 'write_behind' | 'read_through';
|
|
2563
|
+
type EvictionPolicy = 'lru' | 'lfu' | 'fifo' | 'random' | 'ttl';
|
|
2564
|
+
interface CacheConfig {
|
|
2565
|
+
layer: CacheLayer;
|
|
2566
|
+
maxSize: number;
|
|
2567
|
+
maxMemoryMB: number;
|
|
2568
|
+
defaultTTLMs: number;
|
|
2569
|
+
evictionPolicy: EvictionPolicy;
|
|
2570
|
+
warmupEnabled: boolean;
|
|
2571
|
+
compressionEnabled: boolean;
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* releaseManager.ts — SOVR 冻结发布管理器
|
|
2576
|
+
*
|
|
2577
|
+
* 来源文档: 主权AIv1.2冻结发布方案.pdf + SOVRv2.0最终阶段计划.pdf + SOVRv2.0Gamma自动化执行计划.pdf (4 份文档)
|
|
2578
|
+
* 优先级: P1
|
|
2579
|
+
*
|
|
2580
|
+
* 职责:
|
|
2581
|
+
* 1. 版本冻结管理 (Code Freeze / Feature Freeze)
|
|
2582
|
+
* 2. 发布 Checklist 自动化
|
|
2583
|
+
* 3. 回归测试协调
|
|
2584
|
+
* 4. 发布门禁 (Release Gate)
|
|
2585
|
+
* 5. 灰度发布与回滚管理
|
|
2586
|
+
*/
|
|
2587
|
+
type FreezeType = 'feature_freeze' | 'code_freeze' | 'full_freeze';
|
|
2588
|
+
type ReleasePhase = 'planning' | 'development' | 'feature_frozen' | 'code_frozen' | 'testing' | 'staging' | 'canary' | 'rolling' | 'released' | 'rolled_back';
|
|
2589
|
+
type ChecklistItemStatus = 'pending' | 'in_progress' | 'passed' | 'failed' | 'skipped' | 'blocked';
|
|
2590
|
+
interface ReleaseVersion {
|
|
2591
|
+
id: string;
|
|
2592
|
+
version: string;
|
|
2593
|
+
codename: string;
|
|
2594
|
+
phase: ReleasePhase;
|
|
2595
|
+
freezeType?: FreezeType;
|
|
2596
|
+
frozenAt?: number;
|
|
2597
|
+
plannedDate: number;
|
|
2598
|
+
actualDate?: number;
|
|
2599
|
+
owner: string;
|
|
2600
|
+
changelog: string[];
|
|
2601
|
+
blockers: string[];
|
|
2602
|
+
rollbackPlan: string;
|
|
2603
|
+
metadata: Record<string, unknown>;
|
|
2604
|
+
}
|
|
2605
|
+
interface ChecklistItem {
|
|
2606
|
+
id: string;
|
|
2607
|
+
releaseId: string;
|
|
2608
|
+
category: 'build' | 'test' | 'security' | 'performance' | 'docs' | 'infra' | 'approval';
|
|
2609
|
+
name: string;
|
|
2610
|
+
description: string;
|
|
2611
|
+
status: ChecklistItemStatus;
|
|
2612
|
+
assignee: string;
|
|
2613
|
+
completedAt?: number;
|
|
2614
|
+
evidence?: string;
|
|
2615
|
+
required: boolean;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2286
2618
|
/**
|
|
2287
2619
|
* @sovr/engine — Unified Policy Engine
|
|
2288
2620
|
*
|
|
@@ -2499,4 +2831,4 @@ declare class PolicyEngine {
|
|
|
2499
2831
|
}): void;
|
|
2500
2832
|
}
|
|
2501
2833
|
|
|
2502
|
-
export { type ABTestConfig, AdaptiveThresholdManager, type AdaptiveThresholdOptions, type AdjustmentResult, type AggregateSnapshot, type AggregationResult, type AggregationType, type AggregationWindow, type AlertEvent, type AlertSeverity, type AlertThreshold, type AlertType, type AssembledContext, type AttributionRule, type AuditEvent, AutoHardenEngine, type BudgetAlert, type BudgetLevel, type BudgetNode, type CacheEntry, type CapabilityFlags, type Channel, type CircuitBreakerState, type CircuitState, type ComparableInput, type ComparableResult, type ComparisonNode, type CompiledExpression, type ConsistencyMismatch, type ConsistencyResult, type ConstraintConfig, type ConstraintDecision, type ConstraintLevel, type ConstraintMode, type ConstraintState, type ConstraintTrigger, ContextAccelerator, type ContextAcceleratorConfig, type ContextFragment, type ContextPriority, type ContributionDimension, type ContributionEvent, type ContributionScore, ContributionSettlementEngine, type CostAuditEvent, type CostCategory, type CostEstimate, type CostEstimateRequest, type CostGateEnhancedConfig, CostGateEnhancedEngine, type CostRecord, type CostReport, type CostSummary, type DCFInput, type DCFResult, DEFAULT_CA_CONFIG, DEFAULT_GE_CONFIG, DEFAULT_HARD_RULES, DEFAULT_RULES, DEFAULT_SCORING_WEIGHTS, DEFAULT_TSA_CONFIG, type DataPoint, type DecisionFeedback, type DegradationLevel, type DegradeState, type DriftAlert, type DriftAnalyzerConfig, type DriftConfig, type DriftIndex, type DriftPattern, type DriftResult, type DriftWindow, type EligibilityResult, type EngineConfig, type EngineTier, type EngineTierLimits, type EntityType, type EstimateAccuracy, type EvalContext, type EvalRequest, type EvalResult, EvolutionChannelEngine, type EvolutionConfig, type EvolutionEvent, type ExecContext, type ExprTreePolicyRule, type ExpressionNode, type FeatureSwitchDef, type FeatureSwitchState, FeatureSwitchesManager, type FeatureSwitchesOptions, type FunctionNode, type PolicyVersion as GovPolicyVersion, type GovernanceDecision, GovernanceEnhancer, type GovernanceEnhancerConfig, type GovernanceRule, type HardRule, type HardenConfig, type HardenEvent, type HardenLevel, type HardenMeasure, type HardenMeasureType, type HardenState, type HttpContext, type KillSwitchState, type LiteralNode, type LogicalNode, type MarketSize, type McpContext, type ModelCandidate, type ModelPricing, type ModelTier, type MonitoringMetrics, type MultiLevelBudgetConfig, MultiLevelBudgetEngine, type NetworkEffectInput, type NetworkEffectResult, type NotNode, OverrideDriftAnalyzer, type OverrideEvent, type PenaltyCheck, PolicyEngine, type PolicyRule, type PolicySnapshot, type PolicyVersion$1 as PolicyVersion, type PrefetchRule, type PricingEvalRequest, type PricingEvalResult, type PricingRule, PricingRulesEngine, type ProtectiveAction, type ReasonCode, type RecalcEngineConfig, type RecalcGranularity, type RecalcHandler, type RecalcTask, type RecalcTaskStatus, type RecalcTriggerType, RecalculationEngine, type RiskLevel, type RoutingDecision, type RoutingRequest, type RuleCondition, type RuleEvalResult, SOVR_FEATURE_SWITCHES, type ScoreConfigVersion, type ScoringResult, type ScoringWeights, SelfConstraintEngine, SemanticDriftDetectorEngine, type SemanticFingerprint, type SensitivityResult, type SettlementContext, type SqlContext, type SystemState, type ThresholdConfig, type TighteningThresholds, TimeSeriesAggregator, type TimeSeriesAggregatorConfig, type ToolPricing, TrendAlertEngine, type TrendMetric, TwoPhaseRouter, type TwoPhaseRouterConfig, type UnitEconomics, ValuationModel, type ValuationModelConfig, type VariableNode, type Verdict, type WindowType, compileFromJSON, compileRuleSet, createAutoHardenEngine, createCostGateEnhanced, createEvolutionChannel, createMultiLevelBudget, createRecalculationEngine, createSemanticDriftDetector, PolicyEngine as default, estimateCost, evaluateRules, getAccuracyStats, getModelPricingTable, getToolPricingTable, recordActualCost, registerFunction, updateModelPricing, updateToolPricing };
|
|
2834
|
+
export { type ABTestConfig, AdaptiveThresholdManager, type AdaptiveThresholdOptions, type AdjustmentResult, type AggregateSnapshot, type AggregationResult, type AggregationType, type AggregationWindow, type AlertEvent, type AlertSeverity$1 as AlertSeverity, type AlertThreshold, type AlertType, type AssembledContext, type AttributionRule, type AuditEvent, AutoHardenEngine, type BudgetAlert, type BudgetConfig, type BudgetLevel, type BudgetNode, type CacheConfig, type CacheEntry, type CacheLayer, type CacheStrategy, type CapabilityFlags, type CapitalizationResult, type Channel, type ChecklistItem, type ChecklistItemStatus, type CircuitBreakerState, type CircuitState, type ClockDriftReport, type CockpitMetric, type CockpitTimeWindow, type ComparableInput, type ComparableResult, type ComparisonNode, type CompiledExpression, type ConsistencyMismatch, type ConsistencyResult, type ConstraintCheckResult, type ConstraintConfig, type ConstraintDecision, type ConstraintLevel, type ConstraintMode, type ConstraintState, type ConstraintTrigger, ContextAccelerator, type ContextAcceleratorConfig, type ContextFragment, type ContextPriority, type ContributionDimension, type ContributionEvent, type ContributionScore, ContributionSettlementEngine, type CostAlert, type CostAuditEvent, type CostCategory$1 as CostCategory, type CostEntry, type CostEstimate, type CostEstimateRequest, type CostGateEnhancedConfig, CostGateEnhancedEngine, type CostRecord, type CostReport, type CostSummary, type DCFInput, type DCFResult, DEFAULT_CA_CONFIG, DEFAULT_GE_CONFIG, DEFAULT_HARD_RULES, DEFAULT_RULES, DEFAULT_SCORING_WEIGHTS, DEFAULT_TSA_CONFIG, type DataPoint, type DecisionFeedback, type DegradationLevel, type DegradeState, type DriftAlert, type DriftAnalyzerConfig, type DriftConfig, type DriftIndex, type DriftPattern, type DriftResult, type DriftWindow, type EligibilityResult, type EngineConfig, type EngineTier, type EngineTierLimits, type EntityType, type EstimateAccuracy, type EvalContext, type EvalRequest, type EvalResult, type EventOrderValidation, type EvictionPolicy, EvolutionChannelEngine, type EvolutionConfig, type EvolutionEvent, type ExecContext, type ExprTreePolicyRule, type ExpressionNode, type FailureBudget, type FailureCategory, type FailureRecord, type FailureSeverity, type FeasibilityCheck, type FeatureSwitchDef, type FeatureSwitchState, FeatureSwitchesManager, type FeatureSwitchesOptions, type CostCategory as FinOpsCostCategory, type FreezeType, type FunctionNode, type PolicyVersion as GovPolicyVersion, type GovernanceDecision, GovernanceEnhancer, type GovernanceEnhancerConfig, type GovernanceRule, type HardRule, type HardenConfig, type HardenEvent, type HardenLevel, type HardenMeasure, type HardenMeasureType, type HardenState, type HealthScore, type HttpContext, type KillSwitchState, type LiteralNode, type LogicalNode, type MarketSize, type McpContext, type MetricPoint, type ModelCandidate, type ModelPricing, type ModelTier, type MonitoringMetrics, type MultiLevelBudgetConfig, MultiLevelBudgetEngine, type NetworkEffectInput, type NetworkEffectResult, type NotNode, OverrideDriftAnalyzer, type OverrideEvent, type PenaltyCheck, PolicyEngine, type PolicyRule, type PolicySnapshot, type PolicyVersion$1 as PolicyVersion, type PrefetchRule, type PricingEvalRequest, type PricingEvalResult, type PricingRule, PricingRulesEngine, type ProtectiveAction, type RankResult, type RankableItem, type RankingConfig, type RankingSnapshot, type RealityConstraint, type ReasonCode, type RecalcEngineConfig, type RecalcGranularity, type RecalcHandler, type RecalcTask, type RecalcTaskStatus, type RecalcTriggerType, RecalculationEngine, type ReleasePhase, type ReleaseVersion, type RiskLevel, type RoutingDecision, type RoutingRequest, type RuleCondition, type RuleEvalResult, SOVR_FEATURE_SWITCHES, type ScoreConfigVersion, type ScoringResult, type ScoringWeights, SelfConstraintEngine, SemanticDriftDetectorEngine, type SemanticFingerprint, type SensitivityResult, type SettlementContext, type SqlContext, type SystemState, TIME_WINDOWS, type ThresholdConfig, type TighteningThresholds, type TimeConsistencyConfig, TimeSeriesAggregator, type TimeSeriesAggregatorConfig, type TimestampRecord, type ToolPricing, TrendAlertEngine, type TrendMetric, TwoPhaseRouter, type TwoPhaseRouterConfig, type UnitEconomics, ValuationModel, type ValuationModelConfig, type VariableNode, type Verdict, type WindowType, compileFromJSON, compileRuleSet, createAutoHardenEngine, createCostGateEnhanced, createEvolutionChannel, createMultiLevelBudget, createRecalculationEngine, createSemanticDriftDetector, PolicyEngine as default, estimateCost, evaluateRules, getAccuracyStats, getModelPricingTable, getToolPricingTable, recordActualCost, registerFunction, updateModelPricing, updateToolPricing };
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
SOVR_FEATURE_SWITCHES: () => SOVR_FEATURE_SWITCHES,
|
|
43
43
|
SelfConstraintEngine: () => SelfConstraintEngine,
|
|
44
44
|
SemanticDriftDetectorEngine: () => SemanticDriftDetectorEngine,
|
|
45
|
+
TIME_WINDOWS: () => TIME_WINDOWS,
|
|
45
46
|
TimeSeriesAggregator: () => TimeSeriesAggregator,
|
|
46
47
|
TrendAlertEngine: () => TrendAlertEngine,
|
|
47
48
|
TwoPhaseRouter: () => TwoPhaseRouter,
|
|
@@ -4326,6 +4327,60 @@ var OverrideDriftAnalyzer = class {
|
|
|
4326
4327
|
}
|
|
4327
4328
|
};
|
|
4328
4329
|
|
|
4330
|
+
// src/cockpitDataService.ts
|
|
4331
|
+
var TIME_WINDOWS = {
|
|
4332
|
+
"1h": { label: "1 \u5C0F\u65F6", seconds: 3600 },
|
|
4333
|
+
"6h": { label: "6 \u5C0F\u65F6", seconds: 21600 },
|
|
4334
|
+
"24h": { label: "24 \u5C0F\u65F6", seconds: 86400 },
|
|
4335
|
+
"7d": { label: "7 \u5929", seconds: 604800 },
|
|
4336
|
+
"30d": { label: "30 \u5929", seconds: 2592e3 }
|
|
4337
|
+
};
|
|
4338
|
+
var collectors = [];
|
|
4339
|
+
function registerMetricCollector(collector) {
|
|
4340
|
+
const exists = collectors.findIndex((c) => c.name === collector.name);
|
|
4341
|
+
if (exists >= 0) {
|
|
4342
|
+
collectors[exists] = collector;
|
|
4343
|
+
} else {
|
|
4344
|
+
collectors.push(collector);
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
registerMetricCollector({
|
|
4348
|
+
name: "gate_requests_total",
|
|
4349
|
+
category: "gate",
|
|
4350
|
+
unit: "req/min",
|
|
4351
|
+
collect: async () => 0
|
|
4352
|
+
});
|
|
4353
|
+
registerMetricCollector({
|
|
4354
|
+
name: "gate_block_rate",
|
|
4355
|
+
category: "gate",
|
|
4356
|
+
unit: "%",
|
|
4357
|
+
collect: async () => 0
|
|
4358
|
+
});
|
|
4359
|
+
registerMetricCollector({
|
|
4360
|
+
name: "audit_events_total",
|
|
4361
|
+
category: "audit",
|
|
4362
|
+
unit: "events/min",
|
|
4363
|
+
collect: async () => 0
|
|
4364
|
+
});
|
|
4365
|
+
registerMetricCollector({
|
|
4366
|
+
name: "trust_score",
|
|
4367
|
+
category: "trust",
|
|
4368
|
+
unit: "score",
|
|
4369
|
+
collect: async () => 85
|
|
4370
|
+
});
|
|
4371
|
+
registerMetricCollector({
|
|
4372
|
+
name: "budget_utilization",
|
|
4373
|
+
category: "budget",
|
|
4374
|
+
unit: "%",
|
|
4375
|
+
collect: async () => 0
|
|
4376
|
+
});
|
|
4377
|
+
registerMetricCollector({
|
|
4378
|
+
name: "avg_latency_ms",
|
|
4379
|
+
category: "performance",
|
|
4380
|
+
unit: "ms",
|
|
4381
|
+
collect: async () => 0
|
|
4382
|
+
});
|
|
4383
|
+
|
|
4329
4384
|
// src/index.ts
|
|
4330
4385
|
var DEFAULT_RULES = [
|
|
4331
4386
|
// --- HTTP Proxy: Dangerous outbound calls ---
|
|
@@ -4837,6 +4892,7 @@ var index_default = PolicyEngine;
|
|
|
4837
4892
|
SOVR_FEATURE_SWITCHES,
|
|
4838
4893
|
SelfConstraintEngine,
|
|
4839
4894
|
SemanticDriftDetectorEngine,
|
|
4895
|
+
TIME_WINDOWS,
|
|
4840
4896
|
TimeSeriesAggregator,
|
|
4841
4897
|
TrendAlertEngine,
|
|
4842
4898
|
TwoPhaseRouter,
|
package/dist/index.mjs
CHANGED
|
@@ -4257,6 +4257,60 @@ var OverrideDriftAnalyzer = class {
|
|
|
4257
4257
|
}
|
|
4258
4258
|
};
|
|
4259
4259
|
|
|
4260
|
+
// src/cockpitDataService.ts
|
|
4261
|
+
var TIME_WINDOWS = {
|
|
4262
|
+
"1h": { label: "1 \u5C0F\u65F6", seconds: 3600 },
|
|
4263
|
+
"6h": { label: "6 \u5C0F\u65F6", seconds: 21600 },
|
|
4264
|
+
"24h": { label: "24 \u5C0F\u65F6", seconds: 86400 },
|
|
4265
|
+
"7d": { label: "7 \u5929", seconds: 604800 },
|
|
4266
|
+
"30d": { label: "30 \u5929", seconds: 2592e3 }
|
|
4267
|
+
};
|
|
4268
|
+
var collectors = [];
|
|
4269
|
+
function registerMetricCollector(collector) {
|
|
4270
|
+
const exists = collectors.findIndex((c) => c.name === collector.name);
|
|
4271
|
+
if (exists >= 0) {
|
|
4272
|
+
collectors[exists] = collector;
|
|
4273
|
+
} else {
|
|
4274
|
+
collectors.push(collector);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
registerMetricCollector({
|
|
4278
|
+
name: "gate_requests_total",
|
|
4279
|
+
category: "gate",
|
|
4280
|
+
unit: "req/min",
|
|
4281
|
+
collect: async () => 0
|
|
4282
|
+
});
|
|
4283
|
+
registerMetricCollector({
|
|
4284
|
+
name: "gate_block_rate",
|
|
4285
|
+
category: "gate",
|
|
4286
|
+
unit: "%",
|
|
4287
|
+
collect: async () => 0
|
|
4288
|
+
});
|
|
4289
|
+
registerMetricCollector({
|
|
4290
|
+
name: "audit_events_total",
|
|
4291
|
+
category: "audit",
|
|
4292
|
+
unit: "events/min",
|
|
4293
|
+
collect: async () => 0
|
|
4294
|
+
});
|
|
4295
|
+
registerMetricCollector({
|
|
4296
|
+
name: "trust_score",
|
|
4297
|
+
category: "trust",
|
|
4298
|
+
unit: "score",
|
|
4299
|
+
collect: async () => 85
|
|
4300
|
+
});
|
|
4301
|
+
registerMetricCollector({
|
|
4302
|
+
name: "budget_utilization",
|
|
4303
|
+
category: "budget",
|
|
4304
|
+
unit: "%",
|
|
4305
|
+
collect: async () => 0
|
|
4306
|
+
});
|
|
4307
|
+
registerMetricCollector({
|
|
4308
|
+
name: "avg_latency_ms",
|
|
4309
|
+
category: "performance",
|
|
4310
|
+
unit: "ms",
|
|
4311
|
+
collect: async () => 0
|
|
4312
|
+
});
|
|
4313
|
+
|
|
4260
4314
|
// src/index.ts
|
|
4261
4315
|
var DEFAULT_RULES = [
|
|
4262
4316
|
// --- HTTP Proxy: Dangerous outbound calls ---
|
|
@@ -4767,6 +4821,7 @@ export {
|
|
|
4767
4821
|
SOVR_FEATURE_SWITCHES,
|
|
4768
4822
|
SelfConstraintEngine,
|
|
4769
4823
|
SemanticDriftDetectorEngine,
|
|
4824
|
+
TIME_WINDOWS,
|
|
4770
4825
|
TimeSeriesAggregator,
|
|
4771
4826
|
TrendAlertEngine,
|
|
4772
4827
|
TwoPhaseRouter,
|