@company-semantics/contracts 0.28.0 → 0.30.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/package.json +1 -1
- package/src/guards/config.ts +59 -19
- package/src/guards/index.ts +3 -0
- package/src/index.ts +3 -0
package/package.json
CHANGED
package/src/guards/config.ts
CHANGED
|
@@ -269,30 +269,14 @@ export interface MetaBaselines {
|
|
|
269
269
|
*
|
|
270
270
|
* Design invariant: Product repos must NEVER import CI guard code.
|
|
271
271
|
* They export baselines; CI injects guards at runtime.
|
|
272
|
+
*
|
|
273
|
+
* Note: Per-file export/import baselines were removed in favor of
|
|
274
|
+
* AggregateEvolutionConfig. See ADR-CI-029.
|
|
272
275
|
*/
|
|
273
276
|
export interface EvolutionBaselines {
|
|
274
277
|
/** Source directory (explicit, no assumptions). Defaults to 'src' if omitted. */
|
|
275
278
|
srcDir?: string;
|
|
276
279
|
|
|
277
|
-
/** Export count baseline per file. Key is file path relative to srcDir. */
|
|
278
|
-
exports?: Record<string, number>;
|
|
279
|
-
|
|
280
|
-
/** Import count baseline per file. Key is file path relative to srcDir. */
|
|
281
|
-
imports?: Record<string, number>;
|
|
282
|
-
|
|
283
|
-
/** File count baseline per domain. Key is domain path. */
|
|
284
|
-
domains?: Record<string, number>;
|
|
285
|
-
|
|
286
|
-
/** Drift thresholds (optional, guards have sensible defaults) */
|
|
287
|
-
thresholds?: {
|
|
288
|
-
/** Max allowed export drift before warning */
|
|
289
|
-
exportDrift?: number;
|
|
290
|
-
/** Max allowed import drift before warning */
|
|
291
|
-
importDrift?: number;
|
|
292
|
-
/** Max allowed domain file count drift before warning */
|
|
293
|
-
domainDrift?: number;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
280
|
/**
|
|
297
281
|
* Contracts freshness check configuration.
|
|
298
282
|
* CI injects checkContractsFreshness based on this config.
|
|
@@ -325,6 +309,62 @@ export interface EvolutionBaselines {
|
|
|
325
309
|
subdirectoryAffinity?: SubdirectoryAffinityBaseline;
|
|
326
310
|
}
|
|
327
311
|
|
|
312
|
+
// =============================================================================
|
|
313
|
+
// Aggregate Evolution Types
|
|
314
|
+
// =============================================================================
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Domain-level aggregate baseline for evolution tracking.
|
|
318
|
+
* Replaces per-file baselines with domain-aggregated metrics.
|
|
319
|
+
*
|
|
320
|
+
* Design: Domains are extracted from file paths (first 2 segments).
|
|
321
|
+
* Example: 'src/chat/execution/types.ts' → domain 'chat/execution'
|
|
322
|
+
*/
|
|
323
|
+
export interface DomainAggregateBaseline {
|
|
324
|
+
/** Total exports across all files in domain */
|
|
325
|
+
exports: number;
|
|
326
|
+
/** Total imports across all files in domain */
|
|
327
|
+
imports: number;
|
|
328
|
+
/** Diagnostic only, not thresholded */
|
|
329
|
+
fileCount: number;
|
|
330
|
+
/** ISO timestamp when baseline was captured */
|
|
331
|
+
capturedAt?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Configuration for aggregate evolution guard.
|
|
336
|
+
* Uses domain-level metrics instead of per-file tracking.
|
|
337
|
+
*
|
|
338
|
+
* Benefits over per-file:
|
|
339
|
+
* - ~22 entries vs ~300 entries
|
|
340
|
+
* - Stable under refactors within domains
|
|
341
|
+
* - Grows O(domains) not O(files)
|
|
342
|
+
*/
|
|
343
|
+
export interface AggregateEvolutionConfig {
|
|
344
|
+
/** Source directory to scan */
|
|
345
|
+
srcDir: string;
|
|
346
|
+
/** Domain baselines keyed by domain path */
|
|
347
|
+
domains: Record<string, DomainAggregateBaseline>;
|
|
348
|
+
/** Global totals for sanity checking */
|
|
349
|
+
totals?: {
|
|
350
|
+
exports: number;
|
|
351
|
+
imports: number;
|
|
352
|
+
files: number;
|
|
353
|
+
capturedAt?: string;
|
|
354
|
+
};
|
|
355
|
+
/** Warning thresholds (sensible defaults applied if omitted) */
|
|
356
|
+
thresholds?: {
|
|
357
|
+
/** Absolute export growth before warning (default: 10) */
|
|
358
|
+
domainExportGrowth?: number;
|
|
359
|
+
/** Percentage growth before warning (default: 0.25 = 25%) */
|
|
360
|
+
domainGrowthPercent?: number;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// =============================================================================
|
|
365
|
+
// Coverage Baseline Types
|
|
366
|
+
// =============================================================================
|
|
367
|
+
|
|
328
368
|
/**
|
|
329
369
|
* Coverage baseline configuration.
|
|
330
370
|
* Used by CI orchestrator to inject coverage drift guard.
|
package/src/guards/index.ts
CHANGED
|
@@ -54,6 +54,9 @@ export type {
|
|
|
54
54
|
FileClusterBaseline,
|
|
55
55
|
SubdirectoryAffinityBaseline,
|
|
56
56
|
MetaBaselines,
|
|
57
|
+
// Aggregate evolution types
|
|
58
|
+
DomainAggregateBaseline,
|
|
59
|
+
AggregateEvolutionConfig,
|
|
57
60
|
// SOC 2 Guard Configuration types
|
|
58
61
|
SecretsDetectionConfig,
|
|
59
62
|
StructuredLoggingConfig,
|
package/src/index.ts
CHANGED