@company-semantics/contracts 0.18.0 → 0.20.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,6 +46,7 @@
46
46
  "guard:version-tag:json": "npx tsx scripts/ci/version-tag-guard.ts --json",
47
47
  "guard:test": "vitest run scripts/ci/__tests__",
48
48
  "release": "npx tsx scripts/release.ts",
49
+ "prepublishOnly": "pnpm guard:version-tag",
49
50
  "test": "vitest run scripts/ci/__tests__"
50
51
  },
51
52
  "packageManager": "pnpm@10.25.0",
@@ -281,6 +281,26 @@ export interface EvolutionBaselines {
281
281
  * @see ADR-2025-12-014
282
282
  */
283
283
  contractsFreshness?: ContractsFreshnessBaseline;
284
+
285
+ /**
286
+ * Coverage drift check configuration.
287
+ * CI injects checkCoverageDrift based on this config.
288
+ * Errors when coverage drops below baseline (enforced).
289
+ */
290
+ coverage?: CoverageBaseline;
291
+ }
292
+
293
+ /**
294
+ * Coverage baseline configuration.
295
+ * Used by CI orchestrator to inject coverage drift guard.
296
+ */
297
+ export interface CoverageBaseline {
298
+ /** Path to coverage-summary.json (default: 'coverage/coverage-summary.json') */
299
+ coverageFile?: string;
300
+ /** Baseline coverage percentage (lines) */
301
+ baseline: number;
302
+ /** Allowed drop threshold before error (default: 0 = any drop errors) */
303
+ dropThreshold?: number;
284
304
  }
285
305
 
286
306
  /**
@@ -18,10 +18,23 @@ export type {
18
18
  GuardOutput,
19
19
  KnownVulnerability,
20
20
  VulnerabilityConfig,
21
+ // SOC 2 Compliance types
22
+ Soc2ControlArea,
23
+ Soc2ControlStatus,
24
+ Soc2ControlResult,
25
+ Soc2ComplianceOutput,
21
26
  } from './types.js';
22
27
 
23
28
  // Constants (these are type-level, not runtime)
24
- export { GUARD_SCHEMA_VERSION, GUARD_TIERS } from './types.js';
29
+ export {
30
+ GUARD_SCHEMA_VERSION,
31
+ GUARD_TIERS,
32
+ // SOC 2 Compliance constants
33
+ SOC2_CONTROL_NAMES,
34
+ REQUIRED_SOC2_CONTROLS,
35
+ BLOCKING_SOC2_CONTROLS,
36
+ SOC2_SCHEMA_VERSION,
37
+ } from './types.js';
25
38
 
26
39
  // Config types
27
40
  export type {
@@ -36,6 +49,7 @@ export type {
36
49
  VulnerabilitiesBaseline,
37
50
  EvolutionBaselines,
38
51
  ContractsFreshnessBaseline,
52
+ CoverageBaseline,
39
53
  MetaBaselines,
40
54
  } from './config.js';
41
55
 
@@ -158,3 +158,114 @@ export interface VulnerabilityConfig {
158
158
  /** Baseline of known/accepted vulnerabilities (grandfathered) */
159
159
  knownVulnerabilities?: KnownVulnerability[];
160
160
  }
161
+
162
+ // =============================================================================
163
+ // SOC 2 Compliance Types
164
+ // =============================================================================
165
+
166
+ /**
167
+ * SOC 2 control area identifiers.
168
+ * - CM: Change Management
169
+ * - AC: Access Control
170
+ * - LM: Logging & Monitoring
171
+ * - SD: Secure SDLC
172
+ * - BR: Backup & Recovery
173
+ */
174
+ export type Soc2ControlArea = 'CM' | 'AC' | 'LM' | 'SD' | 'BR';
175
+
176
+ /**
177
+ * Control status semantics:
178
+ * - PASS: Control asserted and within bounds
179
+ * - WARN: Control exists but has drift/open findings
180
+ * - FAIL: Control invariant broken
181
+ * - SKIP: Control explicitly out-of-scope for this repo (requires evidence)
182
+ *
183
+ * SKIP rules:
184
+ * - Must include an evidence string explaining why out-of-scope
185
+ * - Is never blocking
186
+ * - Must be explicit (configured in soc2Baselines), not implicit
187
+ */
188
+ export type Soc2ControlStatus = 'PASS' | 'WARN' | 'FAIL' | 'SKIP';
189
+
190
+ /**
191
+ * Human-readable names for SOC 2 control areas.
192
+ */
193
+ export const SOC2_CONTROL_NAMES: Record<Soc2ControlArea, string> = {
194
+ CM: 'Change Management',
195
+ AC: 'Access Control',
196
+ LM: 'Logging & Monitoring',
197
+ SD: 'Secure SDLC',
198
+ BR: 'Backup & Recovery',
199
+ } as const;
200
+
201
+ /**
202
+ * All required SOC 2 controls.
203
+ * Aggregator fails if any control is missing from the output.
204
+ */
205
+ export const REQUIRED_SOC2_CONTROLS: readonly Soc2ControlArea[] = [
206
+ 'CM',
207
+ 'AC',
208
+ 'LM',
209
+ 'SD',
210
+ 'BR',
211
+ ] as const;
212
+
213
+ /**
214
+ * Controls that block CI when status is FAIL.
215
+ * Non-blocking controls report FAIL but don't set exit code to 1.
216
+ */
217
+ export const BLOCKING_SOC2_CONTROLS: readonly Soc2ControlArea[] = ['CM', 'AC'] as const;
218
+
219
+ /**
220
+ * A single SOC 2 control assertion result.
221
+ */
222
+ export interface Soc2ControlResult {
223
+ /** Control area code (e.g., 'CM', 'AC') */
224
+ area: Soc2ControlArea;
225
+ /** Human-readable control name (e.g., 'Change Management') */
226
+ name: string;
227
+ /** Control status */
228
+ status: Soc2ControlStatus;
229
+ /**
230
+ * Evidence describes PROCESS or EXISTENCE, not outcomes.
231
+ * Good: "PR reviews enforced on main", "Backup config present"
232
+ * Bad: "Secure", "Compliant", "Safe"
233
+ */
234
+ evidence: string;
235
+ /** Whether this control blocks CI when status is FAIL */
236
+ blocking: boolean;
237
+ /**
238
+ * Control version for SOC 2 Type II audit trail.
239
+ * Increment when control definition changes materially.
240
+ */
241
+ controlVersion: number;
242
+ /** Underlying guard messages that contributed to this status (if any) */
243
+ messages?: GuardMessage[];
244
+ }
245
+
246
+ /**
247
+ * SOC 2 compliance snapshot output.
248
+ * This is the top-level structure emitted when --soc2 flag is used.
249
+ */
250
+ export interface Soc2ComplianceOutput {
251
+ /** ISO 8601 timestamp of when the compliance check ran */
252
+ timestamp: string;
253
+ /** Repository name */
254
+ repository: string;
255
+ /** Git commit SHA */
256
+ commitSha: string;
257
+ /** CI run ID (if available) */
258
+ ciRunId?: string;
259
+ /** CI run URL (if available) */
260
+ ciRunUrl?: string;
261
+ /** All control results (must include all REQUIRED_SOC2_CONTROLS) */
262
+ controls: Soc2ControlResult[];
263
+ /** Overall pass/fail based on blocking controls only */
264
+ overallStatus: 'PASS' | 'FAIL';
265
+ }
266
+
267
+ /**
268
+ * Current SOC 2 compliance schema version.
269
+ * Bump on breaking schema changes.
270
+ */
271
+ export const SOC2_SCHEMA_VERSION = '1.0.0';
package/src/index.ts CHANGED
@@ -30,16 +30,23 @@ export type {
30
30
  SystemCapability,
31
31
  SystemLayer,
32
32
  SystemCapabilityManifest,
33
- // Graph-based diagram spec (v0.18.0)
33
+ // Graph-based diagram spec (v0.19.0)
34
34
  DiagramNodeKind,
35
35
  DiagramEdgeRelation,
36
36
  EdgeDirection,
37
37
  FlowStage,
38
+ PipelinePhase,
38
39
  DiagramMode,
39
40
  DiagramNode,
40
41
  DiagramEdge,
41
42
  DiagramSpec,
42
43
  DiagramSnapshot,
44
+ // Repository capability types (v0.20.0)
45
+ RepoId,
46
+ CapabilityInvariants,
47
+ RepoCapability,
48
+ CapabilityManifest,
49
+ AggregatedCapabilities,
43
50
  } from './system/index.js'
44
51
 
45
52
  // Guard types (CI guard vocabulary)
@@ -61,6 +68,7 @@ export type {
61
68
  ScriptsDepsBaseline,
62
69
  EvolutionBaselines,
63
70
  ContractsFreshnessBaseline,
71
+ CoverageBaseline,
64
72
  MetaBaselines,
65
73
  } from './guards/index.js'
66
74
 
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Repository Capability Types
3
+ *
4
+ * Types for cross-repo capability registration and aggregation.
5
+ * Used by the system diagram to render repo-level features.
6
+ *
7
+ * Promoted from company-semantics-control/system-diagram/contracts/
8
+ *
9
+ * INVARIANTS:
10
+ * - RepoCapability is a strict superset of DiagramNode
11
+ * - Aggregation transforms RepoCapability → DiagramNode (validate + normalize only)
12
+ * - No semantic changes during aggregation
13
+ * - flowStage is required on repo-level nodes (primary organizing axis)
14
+ *
15
+ * @see ADR-CONTRACTS-NNN in DECISIONS.md
16
+ */
17
+
18
+ import type { DiagramNode, FlowStage, FeatureStatus } from './index.js'
19
+
20
+ // =============================================================================
21
+ // Types
22
+ // =============================================================================
23
+
24
+ /**
25
+ * Valid repository identifiers.
26
+ * Add new repos here as the system grows.
27
+ */
28
+ export type RepoId =
29
+ | 'backend'
30
+ | 'edge'
31
+ | 'app'
32
+ | 'site'
33
+ | 'ci'
34
+ | 'contracts'
35
+ | 'control'
36
+
37
+ /**
38
+ * Semantic invariants for a capability.
39
+ * Used for CI drift detection and diagram styling.
40
+ */
41
+ export interface CapabilityInvariants {
42
+ /** Does this capability invoke LLM/AI APIs? */
43
+ llmCalls: boolean
44
+
45
+ /** Is this an authority boundary (trust/gateway)? */
46
+ authority: boolean
47
+
48
+ /** Can this capability write to strategy/goals? */
49
+ writesStrategy: boolean
50
+ }
51
+
52
+ /**
53
+ * Repository Capability
54
+ *
55
+ * Extends DiagramNode with repo-specific fields.
56
+ * This is what each repo declares in their capabilities.ts.
57
+ *
58
+ * CRITICAL: This extends DiagramNode — do NOT add fields that duplicate
59
+ * or conflict with DiagramNode fields.
60
+ */
61
+ export interface RepoCapability extends DiagramNode {
62
+ /**
63
+ * Which repository owns this capability.
64
+ * Used for aggregation grouping and validation.
65
+ */
66
+ repo: RepoId
67
+
68
+ /**
69
+ * Whether this capability should appear in public diagrams.
70
+ * - true: visible on marketing site, docs
71
+ * - false: internal only, visible in app
72
+ */
73
+ public: boolean
74
+
75
+ /**
76
+ * Architecture layer for horizontal organization.
77
+ * Required for repo-level nodes. The primary organizing axis.
78
+ * Children inherit unless explicitly overridden.
79
+ */
80
+ flowStage?: FlowStage
81
+
82
+ /**
83
+ * Stage-level edges for flow projection.
84
+ * References other capability IDs in format: `repo:domain:capability`
85
+ *
86
+ * Example: ['backend:semantic:processing', 'backend:graph:storage']
87
+ */
88
+ flowsTo?: string[]
89
+
90
+ /**
91
+ * Whether this capability is exported at the architecture level.
92
+ * Exported capabilities represent repo boundaries and API surfaces.
93
+ * Visible in 'architecture' mode.
94
+ */
95
+ exported?: boolean
96
+
97
+ /**
98
+ * Semantic invariants for CI validation.
99
+ * Optional - defaults applied per-repo during aggregation.
100
+ */
101
+ invariants?: Partial<CapabilityInvariants>
102
+ }
103
+
104
+ /**
105
+ * Manifest of capabilities from a single repository.
106
+ *
107
+ * NOTE: No version field — add when actually needed for:
108
+ * - CI compatibility checks
109
+ * - Schema evolution
110
+ * - Breaking capability changes
111
+ */
112
+ export interface CapabilityManifest {
113
+ /** Which repository this manifest is from */
114
+ repo: RepoId
115
+
116
+ /** All capabilities declared by this repo */
117
+ capabilities: RepoCapability[]
118
+ }
119
+
120
+ /**
121
+ * Aggregated capabilities from all repositories.
122
+ * Output of the aggregation step.
123
+ */
124
+ export interface AggregatedCapabilities {
125
+ /** All capabilities from all repos, validated */
126
+ capabilities: RepoCapability[]
127
+
128
+ /** Which repos contributed to this aggregation */
129
+ repos: RepoId[]
130
+
131
+ /** ISO timestamp of aggregation */
132
+ aggregatedAt: string
133
+ }
134
+
135
+ // =============================================================================
136
+ // Re-exports for convenience
137
+ // =============================================================================
138
+
139
+ export type { FeatureStatus, FlowStage }
@@ -88,6 +88,20 @@ export type FlowStage =
88
88
  | 'evaluation' // EVALUATION, GUIDANCE, & AGENTS (MCP)
89
89
  | 'governance' // CI / GOVERNANCE
90
90
 
91
+ /**
92
+ * Data lifecycle phase for coloring/filtering.
93
+ * Secondary annotation — does not affect layout.
94
+ *
95
+ * v0.19.0: New type for pipeline visualization
96
+ */
97
+ export type PipelinePhase =
98
+ | 'source' // External data origin
99
+ | 'ingest' // Data collection and intake
100
+ | 'normalize' // Schema alignment and transformation
101
+ | 'evaluate' // Analysis and decision-making
102
+ | 'store' // Persistence and retrieval
103
+ | 'surface' // Presentation and delivery
104
+
91
105
  /**
92
106
  * Diagram projection modes.
93
107
  * One graph, filtered by mode.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * System Diagram Types (v0.18.0)
2
+ * System Diagram Types (v0.19.0)
3
3
  *
4
4
  * Schema for the system diagram feature.
5
5
  * These types define the contract between:
@@ -11,6 +11,7 @@
11
11
  * - Site displays interactive React Flow diagram
12
12
  * - Snapshots pushed via CI automation
13
13
  *
14
+ * v0.19.0: PipelinePhase annotation for data lifecycle visualization
14
15
  * v0.18.0: Semantic architecture diagram transformation
15
16
  * - Edge semantics (invokes, emits, authorizes, reads)
16
17
  * - FlowStage for architecture layers
@@ -72,9 +73,19 @@ export type {
72
73
  DiagramEdgeRelation,
73
74
  EdgeDirection,
74
75
  FlowStage,
76
+ PipelinePhase,
75
77
  DiagramMode,
76
78
  DiagramNode,
77
79
  DiagramEdge,
78
80
  DiagramSpec,
79
81
  DiagramSnapshot,
80
82
  } from './diagram.js'
83
+
84
+ // Repository capability types
85
+ export type {
86
+ RepoId,
87
+ CapabilityInvariants,
88
+ RepoCapability,
89
+ CapabilityManifest,
90
+ AggregatedCapabilities,
91
+ } from './capabilities.js'