@company-semantics/contracts 0.41.0 → 0.42.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/ci-envelope/index.ts +38 -0
- package/src/ci-envelope/types.ts +216 -0
- package/src/identity/avatar.ts +0 -1
- package/src/index.ts +27 -0
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI Envelope Types Barrel
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all CI execution envelope vocabulary types.
|
|
5
|
+
* Import from '@company-semantics/contracts/ci-envelope' or '@company-semantics/contracts'.
|
|
6
|
+
*
|
|
7
|
+
* Note: This module exports types only (no runtime code per contracts policy).
|
|
8
|
+
* Builder, validation, and policy logic live in company-semantics-ci/envelope/.
|
|
9
|
+
*
|
|
10
|
+
* @see ADR-CONT-033 for contracts boundary rationale
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Types
|
|
14
|
+
export type {
|
|
15
|
+
// Actor & Session
|
|
16
|
+
CIActorInfo,
|
|
17
|
+
CISessionInfo,
|
|
18
|
+
// Intent
|
|
19
|
+
ExecutionIntent,
|
|
20
|
+
CIIntentDeclaration,
|
|
21
|
+
// Scope
|
|
22
|
+
CIChangeKind,
|
|
23
|
+
CIExecutionScope,
|
|
24
|
+
// Authority
|
|
25
|
+
CIAuthorityGrant,
|
|
26
|
+
// Guard Plan
|
|
27
|
+
CIGuardPlan,
|
|
28
|
+
// Status
|
|
29
|
+
CIEnvelopeStatus,
|
|
30
|
+
// Outcome
|
|
31
|
+
CIGuardViolation,
|
|
32
|
+
CIExecutionOutcome,
|
|
33
|
+
// Core Envelope
|
|
34
|
+
CIExecutionEnvelope,
|
|
35
|
+
} from './types';
|
|
36
|
+
|
|
37
|
+
// Constants (documentation/type-level, not runtime)
|
|
38
|
+
export { ENVELOPE_TRANSITIONS } from './types';
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI Execution Envelope Type Vocabulary (v1.0.0)
|
|
3
|
+
*
|
|
4
|
+
* Canonical types for CI execution envelopes — first-class, append-only records
|
|
5
|
+
* that capture AI intent, scope, and authority before mutations occur.
|
|
6
|
+
*
|
|
7
|
+
* Design invariants:
|
|
8
|
+
* - Types only — no validation logic, no policy mappings (those live in CI repo)
|
|
9
|
+
* - Envelope is append-only (status transitions, no field deletions)
|
|
10
|
+
* - Schema version enables future migration
|
|
11
|
+
*
|
|
12
|
+
* @see ADR-CONT-033 for design rationale
|
|
13
|
+
* @see company-semantics-ci/envelope/ for builder and validation logic
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Actor & Session Types
|
|
18
|
+
// =============================================================================
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Actor information for audit trail.
|
|
22
|
+
* Currently Claude-only, extensible for future actor types.
|
|
23
|
+
*/
|
|
24
|
+
export type CIActorInfo = {
|
|
25
|
+
kind: 'claude';
|
|
26
|
+
model: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Session context for correlating envelope to conversation.
|
|
31
|
+
*/
|
|
32
|
+
export type CISessionInfo = {
|
|
33
|
+
conversationId: string;
|
|
34
|
+
turnId: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// Intent Types
|
|
39
|
+
// =============================================================================
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Execution intent categories.
|
|
43
|
+
* Defines the semantic "why" of an execution.
|
|
44
|
+
*
|
|
45
|
+
* Note: Policy mappings (intent → required guards) live in CI repo,
|
|
46
|
+
* not here. This type defines vocabulary only.
|
|
47
|
+
*/
|
|
48
|
+
export type ExecutionIntent =
|
|
49
|
+
| 'feature_extension'
|
|
50
|
+
| 'bug_fix'
|
|
51
|
+
| 'refactor_structural'
|
|
52
|
+
| 'guard_update'
|
|
53
|
+
| 'policy_update'
|
|
54
|
+
| 'schema_change'
|
|
55
|
+
| 'doc_update'
|
|
56
|
+
| 'cleanup'
|
|
57
|
+
| 'experimental';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Intent declaration with optional ADR references.
|
|
61
|
+
*/
|
|
62
|
+
export type CIIntentDeclaration = {
|
|
63
|
+
primary: ExecutionIntent;
|
|
64
|
+
secondary?: ExecutionIntent[];
|
|
65
|
+
description: string;
|
|
66
|
+
adrRefs?: string[];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// =============================================================================
|
|
70
|
+
// Scope Types
|
|
71
|
+
// =============================================================================
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Change kind for scope declarations.
|
|
75
|
+
*/
|
|
76
|
+
export type CIChangeKind = 'add' | 'modify' | 'delete';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Execution scope defining affected repos and paths.
|
|
80
|
+
*/
|
|
81
|
+
export type CIExecutionScope = {
|
|
82
|
+
repos: string[];
|
|
83
|
+
/** Glob patterns for affected paths */
|
|
84
|
+
paths: string[];
|
|
85
|
+
changeKinds: CIChangeKind[];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// =============================================================================
|
|
89
|
+
// Authority Types
|
|
90
|
+
// =============================================================================
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Authority grant documenting permission basis.
|
|
94
|
+
*/
|
|
95
|
+
export type CIAuthorityGrant = {
|
|
96
|
+
/** References to CLAUDE.md / AI_AUTONOMY.md sections */
|
|
97
|
+
allowedBy: string[];
|
|
98
|
+
requiresConfirmation: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// =============================================================================
|
|
102
|
+
// Guard Plan Types
|
|
103
|
+
// =============================================================================
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Guard execution plan resolved from intent + scope.
|
|
107
|
+
* Populated by guard plan resolver in CI repo.
|
|
108
|
+
*/
|
|
109
|
+
export type CIGuardPlan = {
|
|
110
|
+
/** Guard IDs that MUST pass */
|
|
111
|
+
required: string[];
|
|
112
|
+
/** Guard IDs allowed to warn (advisory) */
|
|
113
|
+
advisory: string[];
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// =============================================================================
|
|
117
|
+
// Status Types
|
|
118
|
+
// =============================================================================
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Envelope lifecycle status.
|
|
122
|
+
*
|
|
123
|
+
* State machine:
|
|
124
|
+
* - proposed → validated | blocked
|
|
125
|
+
* - validated → executing | blocked
|
|
126
|
+
* - executing → finalized | blocked
|
|
127
|
+
* - blocked → (terminal)
|
|
128
|
+
* - finalized → (terminal)
|
|
129
|
+
*
|
|
130
|
+
* Note: Transition validation logic lives in CI repo, not here.
|
|
131
|
+
*/
|
|
132
|
+
export type CIEnvelopeStatus =
|
|
133
|
+
| 'proposed'
|
|
134
|
+
| 'validated'
|
|
135
|
+
| 'blocked'
|
|
136
|
+
| 'executing'
|
|
137
|
+
| 'finalized';
|
|
138
|
+
|
|
139
|
+
// =============================================================================
|
|
140
|
+
// Outcome Types
|
|
141
|
+
// =============================================================================
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A single guard violation for post-execution audit.
|
|
145
|
+
*/
|
|
146
|
+
export type CIGuardViolation = {
|
|
147
|
+
guardId: string;
|
|
148
|
+
severity: 'error' | 'warning';
|
|
149
|
+
message: string;
|
|
150
|
+
file?: string;
|
|
151
|
+
line?: number;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Execution outcome populated on finalization.
|
|
156
|
+
*/
|
|
157
|
+
export type CIExecutionOutcome = {
|
|
158
|
+
filesChanged: number;
|
|
159
|
+
commits: string[];
|
|
160
|
+
violations?: CIGuardViolation[];
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// =============================================================================
|
|
164
|
+
// Core Envelope Type
|
|
165
|
+
// =============================================================================
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* CI Execution Envelope — the atomic unit of governed execution.
|
|
169
|
+
*
|
|
170
|
+
* Created before mutations, finalized after. Enables:
|
|
171
|
+
* - Pre-execution gating (intent/scope/authority check)
|
|
172
|
+
* - Post-hoc audit (what was planned vs what happened)
|
|
173
|
+
* - Deterministic explanation (no LLM guesswork)
|
|
174
|
+
*/
|
|
175
|
+
export type CIExecutionEnvelope = {
|
|
176
|
+
/** Schema version for migration (bump on breaking changes) */
|
|
177
|
+
envelopeVersion: 1;
|
|
178
|
+
/** Unique identifier (UUID v7 recommended) */
|
|
179
|
+
executionId: string;
|
|
180
|
+
/** ISO 8601 timestamp */
|
|
181
|
+
createdAt: string;
|
|
182
|
+
actor: CIActorInfo;
|
|
183
|
+
session: CISessionInfo;
|
|
184
|
+
intent: CIIntentDeclaration;
|
|
185
|
+
scope: CIExecutionScope;
|
|
186
|
+
authority: CIAuthorityGrant;
|
|
187
|
+
guardPlan: CIGuardPlan;
|
|
188
|
+
status: CIEnvelopeStatus;
|
|
189
|
+
/** Structured reason when status='blocked' */
|
|
190
|
+
blockedReason?: string;
|
|
191
|
+
/** Populated on finalization */
|
|
192
|
+
outcome?: CIExecutionOutcome;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// =============================================================================
|
|
196
|
+
// Transition Graph (Documentation Only)
|
|
197
|
+
// =============================================================================
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Valid status transitions (documentation only).
|
|
201
|
+
*
|
|
202
|
+
* This const documents the state machine for reference.
|
|
203
|
+
* Actual transition validation logic lives in CI repo.
|
|
204
|
+
*
|
|
205
|
+
* Terminal states: blocked, finalized (empty transition arrays)
|
|
206
|
+
*/
|
|
207
|
+
export const ENVELOPE_TRANSITIONS: Record<
|
|
208
|
+
CIEnvelopeStatus,
|
|
209
|
+
readonly CIEnvelopeStatus[]
|
|
210
|
+
> = {
|
|
211
|
+
proposed: ['validated', 'blocked'],
|
|
212
|
+
validated: ['executing', 'blocked'],
|
|
213
|
+
blocked: [],
|
|
214
|
+
executing: ['finalized', 'blocked'],
|
|
215
|
+
finalized: [],
|
|
216
|
+
} as const;
|
package/src/identity/avatar.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -260,3 +260,30 @@ export {
|
|
|
260
260
|
getExecutionKindDefinition,
|
|
261
261
|
isValidExecutionKind,
|
|
262
262
|
} from './execution/index'
|
|
263
|
+
|
|
264
|
+
// CI Execution Envelope types
|
|
265
|
+
// @see ADR-CONT-033 for contracts boundary rationale
|
|
266
|
+
export type {
|
|
267
|
+
// Actor & Session
|
|
268
|
+
CIActorInfo,
|
|
269
|
+
CISessionInfo,
|
|
270
|
+
// Intent
|
|
271
|
+
ExecutionIntent,
|
|
272
|
+
CIIntentDeclaration,
|
|
273
|
+
// Scope
|
|
274
|
+
CIChangeKind,
|
|
275
|
+
CIExecutionScope,
|
|
276
|
+
// Authority
|
|
277
|
+
CIAuthorityGrant,
|
|
278
|
+
// Guard Plan
|
|
279
|
+
CIGuardPlan,
|
|
280
|
+
// Status
|
|
281
|
+
CIEnvelopeStatus,
|
|
282
|
+
// Outcome
|
|
283
|
+
CIGuardViolation,
|
|
284
|
+
CIExecutionOutcome,
|
|
285
|
+
// Core Envelope
|
|
286
|
+
CIExecutionEnvelope,
|
|
287
|
+
} from './ci-envelope/index'
|
|
288
|
+
|
|
289
|
+
export { ENVELOPE_TRANSITIONS } from './ci-envelope/index'
|