@company-semantics/contracts 0.12.0 → 0.14.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 +5 -1
- package/src/compatibility.ts +35 -0
- package/src/guards/config.ts +76 -0
- package/src/guards/index.ts +2 -0
- package/src/index.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"types": "./src/guards/index.ts",
|
|
17
17
|
"default": "./src/guards/index.ts"
|
|
18
18
|
},
|
|
19
|
+
"./compatibility": {
|
|
20
|
+
"types": "./src/compatibility.ts",
|
|
21
|
+
"default": "./src/compatibility.ts"
|
|
22
|
+
},
|
|
19
23
|
"./schemas/guard-result.schema.json": "./schemas/guard-result.schema.json"
|
|
20
24
|
},
|
|
21
25
|
"types": "./src/index.ts",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts Compatibility Manifest
|
|
3
|
+
*
|
|
4
|
+
* Machine-readable version policy for CI guards.
|
|
5
|
+
* Enables consumer repos to programmatically validate their installed version.
|
|
6
|
+
*
|
|
7
|
+
* @see ADR-2025-12-011 in DECISIONS.md
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Deprecation entry for a semver range.
|
|
12
|
+
* Consumers matching this range will receive advisory warnings.
|
|
13
|
+
*/
|
|
14
|
+
export interface Deprecation {
|
|
15
|
+
/** Semver range (e.g., "0.12.x") */
|
|
16
|
+
range: string
|
|
17
|
+
/** Human-readable reason for deprecation */
|
|
18
|
+
reason: string
|
|
19
|
+
/** Version in which support will be removed */
|
|
20
|
+
removeIn: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compatibility manifest exported as data.
|
|
25
|
+
* CI guards read this to determine freshness warnings/errors.
|
|
26
|
+
*/
|
|
27
|
+
export const COMPATIBILITY = {
|
|
28
|
+
/** Minimum version that all consumers should use */
|
|
29
|
+
minSupported: '0.14.0',
|
|
30
|
+
|
|
31
|
+
/** Versions that still work but should upgrade (with reasons) */
|
|
32
|
+
deprecations: [] as Deprecation[],
|
|
33
|
+
} as const
|
|
34
|
+
|
|
35
|
+
export type Compatibility = typeof COMPATIBILITY
|
package/src/guards/config.ts
CHANGED
|
@@ -136,6 +136,71 @@ export type GuardCheckFactory = (
|
|
|
136
136
|
*/
|
|
137
137
|
export type BoundGuardCheck = () => Promise<CheckResult> | CheckResult;
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Contracts freshness baseline configuration.
|
|
141
|
+
* Consumer repos import COMPATIBILITY from contracts and pass it here.
|
|
142
|
+
*
|
|
143
|
+
* @see ADR-2025-12-014 for design rationale
|
|
144
|
+
*/
|
|
145
|
+
export interface ContractsFreshnessBaseline {
|
|
146
|
+
/** Path to lockfile relative to repo root (e.g., 'pnpm-lock.yaml') */
|
|
147
|
+
lockfilePath: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Compatibility manifest from @company-semantics/contracts.
|
|
151
|
+
* Import and pass directly: `import { COMPATIBILITY } from '@company-semantics/contracts'`
|
|
152
|
+
*/
|
|
153
|
+
compatibility: {
|
|
154
|
+
minSupported: string;
|
|
155
|
+
deprecations: readonly { range: string; reason: string; removeIn: string }[];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Skip this guard. Use for repos with workspace:* dependency (always current).
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
skip?: boolean;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Evolution guard baselines.
|
|
167
|
+
* Product repos provide DATA only; CI orchestrator owns guard implementations.
|
|
168
|
+
*
|
|
169
|
+
* Design invariant: Product repos must NEVER import CI guard code.
|
|
170
|
+
* They export baselines; CI injects guards at runtime.
|
|
171
|
+
*/
|
|
172
|
+
export interface EvolutionBaselines {
|
|
173
|
+
/** Source directory (explicit, no assumptions). Defaults to 'src' if omitted. */
|
|
174
|
+
srcDir?: string;
|
|
175
|
+
|
|
176
|
+
/** Export count baseline per file. Key is file path relative to srcDir. */
|
|
177
|
+
exports?: Record<string, number>;
|
|
178
|
+
|
|
179
|
+
/** Import count baseline per file. Key is file path relative to srcDir. */
|
|
180
|
+
imports?: Record<string, number>;
|
|
181
|
+
|
|
182
|
+
/** File count baseline per domain. Key is domain path. */
|
|
183
|
+
domains?: Record<string, number>;
|
|
184
|
+
|
|
185
|
+
/** Drift thresholds (optional, guards have sensible defaults) */
|
|
186
|
+
thresholds?: {
|
|
187
|
+
/** Max allowed export drift before warning */
|
|
188
|
+
exportDrift?: number;
|
|
189
|
+
/** Max allowed import drift before warning */
|
|
190
|
+
importDrift?: number;
|
|
191
|
+
/** Max allowed domain file count drift before warning */
|
|
192
|
+
domainDrift?: number;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Contracts freshness check configuration.
|
|
197
|
+
* CI injects checkContractsFreshness based on this config.
|
|
198
|
+
*
|
|
199
|
+
* @see ADR-2025-12-014
|
|
200
|
+
*/
|
|
201
|
+
contractsFreshness?: ContractsFreshnessBaseline;
|
|
202
|
+
}
|
|
203
|
+
|
|
139
204
|
/**
|
|
140
205
|
* Registry of checks grouped by tier.
|
|
141
206
|
* Each repo exports this from guard-entries.ts for universal orchestration.
|
|
@@ -152,10 +217,21 @@ export interface GuardCheckRegistry {
|
|
|
152
217
|
structural?: BoundGuardCheck[];
|
|
153
218
|
behavioral?: BoundGuardCheck[];
|
|
154
219
|
invariants?: BoundGuardCheck[];
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Evolution guards are CI-owned. Use evolutionBaselines instead.
|
|
222
|
+
* Product repos should not provide evolution check implementations.
|
|
223
|
+
*/
|
|
155
224
|
evolution?: BoundGuardCheck[];
|
|
156
225
|
/** Meta-guards: protect the guard system itself (coverage correctness) */
|
|
157
226
|
meta?: BoundGuardCheck[];
|
|
158
227
|
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Evolution guard baselines.
|
|
231
|
+
* CI orchestrator injects evolution guards based on these baselines.
|
|
232
|
+
* Product repos provide data only, never guard implementations.
|
|
233
|
+
*/
|
|
234
|
+
evolutionBaselines?: EvolutionBaselines;
|
|
159
235
|
}
|
|
160
236
|
|
|
161
237
|
// =============================================================================
|
package/src/guards/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -55,6 +55,8 @@ export type {
|
|
|
55
55
|
GuardCheckFactory,
|
|
56
56
|
BoundGuardCheck,
|
|
57
57
|
GuardCheckRegistry,
|
|
58
|
+
EvolutionBaselines,
|
|
59
|
+
ContractsFreshnessBaseline,
|
|
58
60
|
} from './guards/index.js'
|
|
59
61
|
|
|
60
62
|
export {
|
|
@@ -64,3 +66,8 @@ export {
|
|
|
64
66
|
DEFAULT_DOMAIN_SECTIONS,
|
|
65
67
|
DEFAULT_INFRA_SECTIONS,
|
|
66
68
|
} from './guards/index.js'
|
|
69
|
+
|
|
70
|
+
// Compatibility manifest (CI guard vocabulary)
|
|
71
|
+
// @see ADR-2025-12-011 for design rationale
|
|
72
|
+
export { COMPATIBILITY } from './compatibility.js'
|
|
73
|
+
export type { Compatibility, Deprecation } from './compatibility.js'
|