@neurcode-ai/contracts 0.1.2 → 0.1.3
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/admission/framing.d.ts +38 -0
- package/dist/admission/framing.d.ts.map +1 -0
- package/dist/admission/framing.js +78 -0
- package/dist/admission/framing.js.map +1 -0
- package/dist/admission/index.d.ts +4 -0
- package/dist/admission/index.d.ts.map +1 -0
- package/dist/admission/index.js +37 -0
- package/dist/admission/index.js.map +1 -0
- package/dist/admission/privacy.d.ts +23 -0
- package/dist/admission/privacy.d.ts.map +1 -0
- package/dist/admission/privacy.js +99 -0
- package/dist/admission/privacy.js.map +1 -0
- package/dist/admission/schema.d.ts +277 -0
- package/dist/admission/schema.d.ts.map +1 -0
- package/dist/admission/schema.js +156 -0
- package/dist/admission/schema.js.map +1 -0
- package/dist/index.d.ts +91 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +182 -17
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +522 -0
- package/dist/intelligence.d.ts.map +1 -0
- package/dist/intelligence.js +5 -0
- package/dist/intelligence.js.map +1 -0
- package/dist/remediation/capabilities.d.ts +36 -0
- package/dist/remediation/capabilities.d.ts.map +1 -0
- package/dist/remediation/capabilities.js +7 -0
- package/dist/remediation/capabilities.js.map +1 -0
- package/dist/remediation/index.d.ts +5 -0
- package/dist/remediation/index.d.ts.map +1 -0
- package/dist/remediation/index.js +3 -0
- package/dist/remediation/index.js.map +1 -0
- package/dist/remediation/request.d.ts +183 -0
- package/dist/remediation/request.d.ts.map +1 -0
- package/dist/remediation/request.js +15 -0
- package/dist/remediation/request.js.map +1 -0
- package/dist/remediation/response.d.ts +100 -0
- package/dist/remediation/response.d.ts.map +1 -0
- package/dist/remediation/response.js +11 -0
- package/dist/remediation/response.js.map +1 -0
- package/dist/remediation/validation.d.ts +87 -0
- package/dist/remediation/validation.d.ts.map +1 -0
- package/dist/remediation/validation.js +15 -0
- package/dist/remediation/validation.js.map +1 -0
- package/dist/status-vocabulary.d.ts +45 -0
- package/dist/status-vocabulary.d.ts.map +1 -0
- package/dist/status-vocabulary.js +101 -0
- package/dist/status-vocabulary.js.map +1 -0
- package/dist/verification/canonical-finding.d.ts +171 -0
- package/dist/verification/canonical-finding.d.ts.map +1 -0
- package/dist/verification/canonical-finding.js +3 -0
- package/dist/verification/canonical-finding.js.map +1 -0
- package/dist/verification/index.d.ts +6 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +11 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/pipeline.d.ts +134 -0
- package/dist/verification/pipeline.d.ts.map +1 -0
- package/dist/verification/pipeline.js +57 -0
- package/dist/verification/pipeline.js.map +1 -0
- package/dist/verification/taxonomy.d.ts +10 -0
- package/dist/verification/taxonomy.d.ts.map +1 -0
- package/dist/verification/taxonomy.js +16 -0
- package/dist/verification/taxonomy.js.map +1 -0
- package/package.json +1 -1
- package/src/admission/admission-framing.test.ts +93 -0
- package/src/admission/framing.ts +78 -0
- package/src/admission/index.ts +58 -0
- package/src/admission/privacy.ts +93 -0
- package/src/admission/schema.ts +392 -0
- package/src/index.ts +266 -26
- package/src/intelligence.ts +698 -0
- package/src/remediation/capabilities.ts +53 -0
- package/src/remediation/index.ts +29 -0
- package/src/remediation/request.ts +236 -0
- package/src/remediation/response.ts +129 -0
- package/src/remediation/validation.ts +109 -0
- package/src/status-vocabulary.ts +125 -0
- package/src/verification/canonical-finding.ts +196 -0
- package/src/verification/index.ts +41 -0
- package/src/verification/pipeline.ts +199 -0
- package/src/verification/taxonomy.ts +46 -0
package/src/index.ts
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
export const CLI_JSON_CONTRACT_VERSION = '2026-
|
|
1
|
+
export const CLI_JSON_CONTRACT_VERSION = '2026-05-11';
|
|
2
|
+
|
|
3
|
+
/** Compare YYYY-MM-DD contract stamps; returns null when either side is unparsable. */
|
|
4
|
+
export function compareCalendarContractVersion(left: string, right: string): number | null {
|
|
5
|
+
const parse = (value: string): number | null => {
|
|
6
|
+
const match = /^(\d{4}-\d{2}-\d{2})/.exec(value.trim());
|
|
7
|
+
if (!match) return null;
|
|
8
|
+
const ms = Date.parse(`${match[1]}T00:00:00.000Z`);
|
|
9
|
+
return Number.isNaN(ms) ? null : ms;
|
|
10
|
+
};
|
|
11
|
+
const leftMs = parse(left);
|
|
12
|
+
const rightMs = parse(right);
|
|
13
|
+
if (leftMs === null || rightMs === null) return null;
|
|
14
|
+
if (leftMs === rightMs) return 0;
|
|
15
|
+
return leftMs < rightMs ? -1 : 1;
|
|
16
|
+
}
|
|
17
|
+
export * from './intelligence';
|
|
18
|
+
export * from './status-vocabulary';
|
|
19
|
+
export * from './verification';
|
|
20
|
+
export * from './remediation';
|
|
21
|
+
export * from './admission';
|
|
2
22
|
export const RUNTIME_COMPATIBILITY_CONTRACT_ID = 'neurcode-runtime-compatibility';
|
|
3
23
|
export const RUNTIME_COMPATIBILITY_CONTRACT_VERSION = '2026-04-04';
|
|
4
|
-
export const RUNTIME_COMPATIBILITY_MANIFEST_VERSION = '2026-
|
|
24
|
+
export const RUNTIME_COMPATIBILITY_MANIFEST_VERSION = '2026-06-02.1';
|
|
5
25
|
export const RUNTIME_COMPATIBILITY_MANIFEST_SCHEMA_VERSION = 1;
|
|
6
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Runtime Admission contract (Phase A — Provenance Core). Additive: surfaces a
|
|
29
|
+
* version for the self-attested admission artifact + coverage manifest so the
|
|
30
|
+
* future Action and backend can negotiate compatibility. No enforcement yet.
|
|
31
|
+
*/
|
|
32
|
+
export const ADMISSION_CONTRACT_ID = 'neurcode-runtime-admission';
|
|
33
|
+
export const ADMISSION_CONTRACT_VERSION = '2026-06-02';
|
|
34
|
+
|
|
7
35
|
export type RuntimeComponent = 'cli' | 'action' | 'api';
|
|
8
36
|
|
|
9
37
|
export type RuntimeMinimumPeerVersions = Partial<Record<RuntimeComponent, string>>;
|
|
@@ -21,6 +49,8 @@ export interface RuntimeCompatibilityManifest {
|
|
|
21
49
|
contractId: string;
|
|
22
50
|
runtimeContractVersion: string;
|
|
23
51
|
cliJsonContractVersion: string;
|
|
52
|
+
/** Runtime Admission provenance contract version (additive; Phase A). */
|
|
53
|
+
admissionContractVersion: string;
|
|
24
54
|
minimumPeerVersions: Record<RuntimeComponent, RuntimeMinimumPeerVersions>;
|
|
25
55
|
validatedTriplets: RuntimeCompatibilityTriplet[];
|
|
26
56
|
}
|
|
@@ -31,6 +61,7 @@ const RUNTIME_COMPATIBILITY_MANIFEST: RuntimeCompatibilityManifest = {
|
|
|
31
61
|
contractId: RUNTIME_COMPATIBILITY_CONTRACT_ID,
|
|
32
62
|
runtimeContractVersion: RUNTIME_COMPATIBILITY_CONTRACT_VERSION,
|
|
33
63
|
cliJsonContractVersion: CLI_JSON_CONTRACT_VERSION,
|
|
64
|
+
admissionContractVersion: ADMISSION_CONTRACT_VERSION,
|
|
34
65
|
minimumPeerVersions: {
|
|
35
66
|
cli: {
|
|
36
67
|
action: '0.2.1',
|
|
@@ -50,8 +81,8 @@ const RUNTIME_COMPATIBILITY_MANIFEST: RuntimeCompatibilityManifest = {
|
|
|
50
81
|
id: 'current',
|
|
51
82
|
channel: 'current',
|
|
52
83
|
versions: {
|
|
53
|
-
cli: '0.
|
|
54
|
-
action: '0.2.
|
|
84
|
+
cli: '0.14.0',
|
|
85
|
+
action: '0.2.4',
|
|
55
86
|
api: '0.2.0',
|
|
56
87
|
},
|
|
57
88
|
notes: 'Current release train validated in monorepo CI.',
|
|
@@ -75,6 +106,7 @@ const RUNTIME_MINIMUM_PEER_VERSIONS: Record<RuntimeComponent, RuntimeMinimumPeer
|
|
|
75
106
|
export function getRuntimeCompatibilityManifest(): RuntimeCompatibilityManifest {
|
|
76
107
|
return {
|
|
77
108
|
...RUNTIME_COMPATIBILITY_MANIFEST,
|
|
109
|
+
admissionContractVersion: RUNTIME_COMPATIBILITY_MANIFEST.admissionContractVersion,
|
|
78
110
|
minimumPeerVersions: {
|
|
79
111
|
cli: { ...RUNTIME_COMPATIBILITY_MANIFEST.minimumPeerVersions.cli },
|
|
80
112
|
action: { ...RUNTIME_COMPATIBILITY_MANIFEST.minimumPeerVersions.action },
|
|
@@ -92,6 +124,8 @@ export interface RuntimeCompatibilityDescriptor {
|
|
|
92
124
|
runtimeContractVersion: string;
|
|
93
125
|
cliJsonContractVersion: string;
|
|
94
126
|
manifestVersion?: string;
|
|
127
|
+
/** Runtime Admission provenance contract version (additive; optional for legacy peers). */
|
|
128
|
+
admissionContractVersion?: string;
|
|
95
129
|
component: RuntimeComponent;
|
|
96
130
|
componentVersion: string;
|
|
97
131
|
minimumPeerVersions: RuntimeMinimumPeerVersions;
|
|
@@ -121,18 +155,86 @@ export interface CliApplyJsonPayload extends CliContractBase {
|
|
|
121
155
|
message: string;
|
|
122
156
|
}
|
|
123
157
|
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
158
|
+
export type VerifyVerdict = 'PASS' | 'WARN' | 'FAIL';
|
|
159
|
+
export type VerifySeverity = 'critical' | 'high' | 'warning' | 'info';
|
|
160
|
+
|
|
161
|
+
export interface VerifyOutputSummary {
|
|
162
|
+
totalFilesChanged: number;
|
|
163
|
+
totalViolations: number;
|
|
164
|
+
totalWarnings: number;
|
|
165
|
+
totalScopeIssues: number;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface VerifyOutputViolation {
|
|
169
|
+
file: string;
|
|
129
170
|
message: string;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
policyCompilation?: Record<string, unknown>;
|
|
133
|
-
changeContract?: Record<string, unknown>;
|
|
171
|
+
policy: string;
|
|
172
|
+
severity: VerifySeverity;
|
|
134
173
|
}
|
|
135
174
|
|
|
175
|
+
export interface VerifyOutputWarning {
|
|
176
|
+
file: string;
|
|
177
|
+
message: string;
|
|
178
|
+
policy: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type VerifyScopeIssuePolicy = 'forbidden' | 'review-required' | 'out-of-scope' | 'generated-code' | 'unscoped';
|
|
182
|
+
export type VerifyScopeIssueBoundaryType = 'sensitive' | 'infra' | 'ci' | 'dependency-manifest' | 'service' | 'module' | 'generated-code' | 'unspecified';
|
|
183
|
+
|
|
184
|
+
export type VerifyImportEdgeKind = 'static' | 'relative' | 'dynamic' | 'require' | 'side-effect';
|
|
185
|
+
export type VerifyImportEdgeLanguage = 'python' | 'typescript' | 'javascript';
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Discriminator metadata attached to a scope issue when the breach was
|
|
189
|
+
* detected through an import edge rather than a touched file path.
|
|
190
|
+
* Present iff the scope issue originated from `evaluateImportEdgeGovernance`.
|
|
191
|
+
*/
|
|
192
|
+
export interface VerifyOutputImportEdge {
|
|
193
|
+
sourceFile: string;
|
|
194
|
+
sourceLine: number;
|
|
195
|
+
importTarget: string;
|
|
196
|
+
resolvedTargetPath: string;
|
|
197
|
+
resolvedBoundary: string;
|
|
198
|
+
edgeKind: VerifyImportEdgeKind;
|
|
199
|
+
language: VerifyImportEdgeLanguage;
|
|
200
|
+
deterministic: true;
|
|
201
|
+
replayStable: true;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface VerifyOutputScopeIssue {
|
|
205
|
+
file: string;
|
|
206
|
+
message: string;
|
|
207
|
+
/**
|
|
208
|
+
* Severity / governance classification of the scope issue.
|
|
209
|
+
* Optional for backward compatibility with pre-runtime-activation payloads.
|
|
210
|
+
*/
|
|
211
|
+
policy?: VerifyScopeIssuePolicy;
|
|
212
|
+
/**
|
|
213
|
+
* Boundary category this file touched (when known). Optional so legacy
|
|
214
|
+
* payloads remain valid.
|
|
215
|
+
*/
|
|
216
|
+
boundaryType?: VerifyScopeIssueBoundaryType;
|
|
217
|
+
/**
|
|
218
|
+
* Set on issues raised by the deterministic import-edge governance layer
|
|
219
|
+
* (an allowed source file importing from a forbidden boundary).
|
|
220
|
+
*/
|
|
221
|
+
importEdge?: VerifyOutputImportEdge;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface VerifyOutput {
|
|
225
|
+
verdict: VerifyVerdict;
|
|
226
|
+
summary: VerifyOutputSummary;
|
|
227
|
+
violations: VerifyOutputViolation[];
|
|
228
|
+
warnings: VerifyOutputWarning[];
|
|
229
|
+
scopeIssues: VerifyOutputScopeIssue[];
|
|
230
|
+
driftScore?: number;
|
|
231
|
+
/** Canonical governance model (additive; absent in legacy payloads). */
|
|
232
|
+
governanceVerification?: import('./verification').GovernanceVerificationEnvelope;
|
|
233
|
+
governanceFindings?: import('./verification').GovernanceFinding[];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type CliVerifyJsonPayload = VerifyOutput;
|
|
237
|
+
|
|
136
238
|
export interface CliPromptJsonPayload extends CliContractBase {
|
|
137
239
|
success: boolean;
|
|
138
240
|
planId: string | null;
|
|
@@ -151,6 +253,8 @@ export interface CliContractImportJsonPayload extends CliContractBase {
|
|
|
151
253
|
projectId: string | null;
|
|
152
254
|
parseMode: 'json' | 'text' | null;
|
|
153
255
|
importedFiles: number;
|
|
256
|
+
sourcePath?: string | null;
|
|
257
|
+
autoDetect?: Record<string, unknown> | null;
|
|
154
258
|
warnings: unknown[];
|
|
155
259
|
changeContract?: Record<string, unknown> | null;
|
|
156
260
|
message: string;
|
|
@@ -250,6 +354,11 @@ function asOptionalString(record: Record<string, unknown>, key: string, label: s
|
|
|
250
354
|
return value;
|
|
251
355
|
}
|
|
252
356
|
|
|
357
|
+
function asIntegerNumber(record: Record<string, unknown>, key: string, label: string): number {
|
|
358
|
+
const value = asNumber(record, key, label);
|
|
359
|
+
return Math.max(0, Math.floor(value));
|
|
360
|
+
}
|
|
361
|
+
|
|
253
362
|
function asContractVersion(record: Record<string, unknown>): string | undefined {
|
|
254
363
|
const value = record.contractVersion;
|
|
255
364
|
if (value === undefined) return undefined;
|
|
@@ -295,6 +404,7 @@ function parseRuntimeCompatibilityDescriptor(
|
|
|
295
404
|
runtimeContractVersion: asString(record, 'runtimeContractVersion', `${label}.compatibility`),
|
|
296
405
|
cliJsonContractVersion: asString(record, 'cliJsonContractVersion', `${label}.compatibility`),
|
|
297
406
|
manifestVersion: asOptionalString(record, 'manifestVersion', `${label}.compatibility`),
|
|
407
|
+
admissionContractVersion: asOptionalString(record, 'admissionContractVersion', `${label}.compatibility`),
|
|
298
408
|
component: asRuntimeComponent(record, 'component', `${label}.compatibility`),
|
|
299
409
|
componentVersion: asString(record, 'componentVersion', `${label}.compatibility`),
|
|
300
410
|
minimumPeerVersions: parseRuntimeMinimumPeerVersions(record.minimumPeerVersions, `${label}.compatibility`),
|
|
@@ -355,6 +465,7 @@ export function buildRuntimeCompatibilityDescriptor(
|
|
|
355
465
|
runtimeContractVersion: RUNTIME_COMPATIBILITY_CONTRACT_VERSION,
|
|
356
466
|
cliJsonContractVersion: CLI_JSON_CONTRACT_VERSION,
|
|
357
467
|
manifestVersion: RUNTIME_COMPATIBILITY_MANIFEST_VERSION,
|
|
468
|
+
admissionContractVersion: ADMISSION_CONTRACT_VERSION,
|
|
358
469
|
component,
|
|
359
470
|
componentVersion,
|
|
360
471
|
minimumPeerVersions: { ...RUNTIME_MINIMUM_PEER_VERSIONS[component] },
|
|
@@ -430,21 +541,150 @@ export function parseCliApplyJsonPayload(value: unknown, label = 'apply'): CliAp
|
|
|
430
541
|
}
|
|
431
542
|
|
|
432
543
|
export function parseCliVerifyJsonPayload(value: unknown, label = 'verify'): CliVerifyJsonPayload {
|
|
544
|
+
return parseVerifyOutput(value, label);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function parseVerifyOutput(value: unknown, label = 'verify'): VerifyOutput {
|
|
433
548
|
const record = asRecord(value, label);
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
549
|
+
const verdictRaw = asString(record, 'verdict', label).trim().toUpperCase();
|
|
550
|
+
if (verdictRaw !== 'PASS' && verdictRaw !== 'WARN' && verdictRaw !== 'FAIL') {
|
|
551
|
+
throw new Error(`${label}: expected verdict:"PASS"|"WARN"|"FAIL"`);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const summaryRecord = asRecord(record.summary, `${label}.summary`);
|
|
555
|
+
const summary: VerifyOutputSummary = {
|
|
556
|
+
totalFilesChanged: asIntegerNumber(summaryRecord, 'totalFilesChanged', `${label}.summary`),
|
|
557
|
+
totalViolations: asIntegerNumber(summaryRecord, 'totalViolations', `${label}.summary`),
|
|
558
|
+
totalWarnings: asIntegerNumber(summaryRecord, 'totalWarnings', `${label}.summary`),
|
|
559
|
+
totalScopeIssues: asIntegerNumber(summaryRecord, 'totalScopeIssues', `${label}.summary`),
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
const violations = asArray(record, 'violations', label).map((entry, index) => {
|
|
563
|
+
const item = asRecord(entry, `${label}.violations[${index}]`);
|
|
564
|
+
const severity = asString(item, 'severity', `${label}.violations[${index}]`).trim().toLowerCase();
|
|
565
|
+
if (severity !== 'critical' && severity !== 'high' && severity !== 'warning' && severity !== 'info') {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`${label}.violations[${index}]: expected severity:"critical"|"high"|"warning"|"info"`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
file: asString(item, 'file', `${label}.violations[${index}]`),
|
|
572
|
+
message: asString(item, 'message', `${label}.violations[${index}]`),
|
|
573
|
+
policy: asString(item, 'policy', `${label}.violations[${index}]`),
|
|
574
|
+
severity,
|
|
575
|
+
} as VerifyOutputViolation;
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const warnings = asArray(record, 'warnings', label).map((entry, index) => {
|
|
579
|
+
const item = asRecord(entry, `${label}.warnings[${index}]`);
|
|
580
|
+
return {
|
|
581
|
+
file: asString(item, 'file', `${label}.warnings[${index}]`),
|
|
582
|
+
message: asString(item, 'message', `${label}.warnings[${index}]`),
|
|
583
|
+
policy: asString(item, 'policy', `${label}.warnings[${index}]`),
|
|
584
|
+
} as VerifyOutputWarning;
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
const scopeIssues = asArray(record, 'scopeIssues', label).map((entry, index) => {
|
|
588
|
+
const item = asRecord(entry, `${label}.scopeIssues[${index}]`);
|
|
589
|
+
const issue: VerifyOutputScopeIssue = {
|
|
590
|
+
file: asString(item, 'file', `${label}.scopeIssues[${index}]`),
|
|
591
|
+
message: asString(item, 'message', `${label}.scopeIssues[${index}]`),
|
|
592
|
+
};
|
|
593
|
+
const rawPolicy = item.policy;
|
|
594
|
+
if (typeof rawPolicy === 'string' && rawPolicy.length > 0) {
|
|
595
|
+
const allowedPolicies: VerifyScopeIssuePolicy[] = ['forbidden', 'review-required', 'out-of-scope', 'generated-code', 'unscoped'];
|
|
596
|
+
if ((allowedPolicies as string[]).includes(rawPolicy)) {
|
|
597
|
+
issue.policy = rawPolicy as VerifyScopeIssuePolicy;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const rawBoundary = item.boundaryType;
|
|
601
|
+
if (typeof rawBoundary === 'string' && rawBoundary.length > 0) {
|
|
602
|
+
const allowedBoundaries: VerifyScopeIssueBoundaryType[] = [
|
|
603
|
+
'sensitive', 'infra', 'ci', 'dependency-manifest', 'service', 'module', 'generated-code', 'unspecified',
|
|
604
|
+
];
|
|
605
|
+
if ((allowedBoundaries as string[]).includes(rawBoundary)) {
|
|
606
|
+
issue.boundaryType = rawBoundary as VerifyScopeIssueBoundaryType;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const rawImportEdge = item.importEdge;
|
|
610
|
+
if (rawImportEdge && typeof rawImportEdge === 'object' && !Array.isArray(rawImportEdge)) {
|
|
611
|
+
const edgeRecord = rawImportEdge as Record<string, unknown>;
|
|
612
|
+
const allowedEdgeKinds: VerifyImportEdgeKind[] = ['static', 'relative', 'dynamic', 'require', 'side-effect'];
|
|
613
|
+
const allowedEdgeLanguages: VerifyImportEdgeLanguage[] = ['python', 'typescript', 'javascript'];
|
|
614
|
+
const sourceFile = edgeRecord.sourceFile;
|
|
615
|
+
const importTarget = edgeRecord.importTarget;
|
|
616
|
+
const resolvedTargetPath = edgeRecord.resolvedTargetPath;
|
|
617
|
+
const resolvedBoundary = edgeRecord.resolvedBoundary;
|
|
618
|
+
const sourceLine = edgeRecord.sourceLine;
|
|
619
|
+
const edgeKind = edgeRecord.edgeKind;
|
|
620
|
+
const language = edgeRecord.language;
|
|
621
|
+
if (
|
|
622
|
+
typeof sourceFile === 'string'
|
|
623
|
+
&& typeof importTarget === 'string'
|
|
624
|
+
&& typeof resolvedTargetPath === 'string'
|
|
625
|
+
&& typeof resolvedBoundary === 'string'
|
|
626
|
+
&& typeof sourceLine === 'number'
|
|
627
|
+
&& Number.isFinite(sourceLine)
|
|
628
|
+
&& typeof edgeKind === 'string'
|
|
629
|
+
&& typeof language === 'string'
|
|
630
|
+
&& (allowedEdgeKinds as string[]).includes(edgeKind)
|
|
631
|
+
&& (allowedEdgeLanguages as string[]).includes(language)
|
|
632
|
+
) {
|
|
633
|
+
issue.importEdge = {
|
|
634
|
+
sourceFile,
|
|
635
|
+
sourceLine,
|
|
636
|
+
importTarget,
|
|
637
|
+
resolvedTargetPath,
|
|
638
|
+
resolvedBoundary,
|
|
639
|
+
edgeKind: edgeKind as VerifyImportEdgeKind,
|
|
640
|
+
language: language as VerifyImportEdgeLanguage,
|
|
641
|
+
deterministic: true,
|
|
642
|
+
replayStable: true,
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return issue;
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
const driftScoreRaw = record.driftScore;
|
|
650
|
+
const driftScore =
|
|
651
|
+
driftScoreRaw === undefined
|
|
652
|
+
? undefined
|
|
653
|
+
: (typeof driftScoreRaw === 'number' && Number.isFinite(driftScoreRaw)
|
|
654
|
+
? Math.round(Math.max(0, Math.min(100, driftScoreRaw)))
|
|
655
|
+
: (() => {
|
|
656
|
+
throw new Error(`${label}: expected driftScore:number when present`);
|
|
657
|
+
})());
|
|
658
|
+
|
|
659
|
+
const governanceFindingsRaw = record.governanceFindings;
|
|
660
|
+
if (governanceFindingsRaw !== undefined && !Array.isArray(governanceFindingsRaw)) {
|
|
661
|
+
throw new Error(`${label}: expected governanceFindings:array when present`);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const governanceVerificationRaw = record.governanceVerification;
|
|
665
|
+
if (
|
|
666
|
+
governanceVerificationRaw !== undefined
|
|
667
|
+
&& (typeof governanceVerificationRaw !== 'object' || governanceVerificationRaw === null || Array.isArray(governanceVerificationRaw))
|
|
668
|
+
) {
|
|
669
|
+
throw new Error(`${label}: expected governanceVerification:object when present`);
|
|
670
|
+
}
|
|
671
|
+
|
|
438
672
|
return {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
673
|
+
verdict: verdictRaw,
|
|
674
|
+
summary,
|
|
675
|
+
violations,
|
|
676
|
+
warnings,
|
|
677
|
+
scopeIssues,
|
|
678
|
+
...(typeof driftScore === 'number' ? { driftScore } : {}),
|
|
679
|
+
...(governanceFindingsRaw !== undefined
|
|
680
|
+
? { governanceFindings: governanceFindingsRaw as import('./verification').GovernanceFinding[] }
|
|
681
|
+
: {}),
|
|
682
|
+
...(governanceVerificationRaw !== undefined
|
|
683
|
+
? {
|
|
684
|
+
governanceVerification:
|
|
685
|
+
governanceVerificationRaw as import('./verification').GovernanceVerificationEnvelope,
|
|
686
|
+
}
|
|
687
|
+
: {}),
|
|
448
688
|
};
|
|
449
689
|
}
|
|
450
690
|
|