@dynamicalsystems/idl-conformance 0.11.0 → 0.13.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/assets/vectors/dsg.extension.release_1/accept/compute-release.json +8 -0
- package/assets/vectors/dsg.extension.release_1/accept/noncompute-release-without-fake-compute.json +8 -0
- package/assets/vectors/dsg.extension.release_1/accept/signature-binds-canonical-body.json +9 -0
- package/assets/vectors/dsg.extension.release_1/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.extension.release_1/reject/component-dependency-cycle.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/compute-requires-job-class.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/duplicate-component-id-with-different-body.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/missing-component-dependency.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/mutable-release-status-forbidden.json +8 -0
- package/assets/vectors/dsg.extension.release_1/reject/noncompute-cannot-claim-artifact.json +8 -0
- package/assets/vectors/dsg.extension.release_1/reject/signature-rejects-altered-signature.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/signature-rejects-substituted-body-digest.json +9 -0
- package/assets/vectors/dsg.extension.release_1/reject/signature-rejects-wrong-key.json +9 -0
- package/assets/vectors/dsg.organization.release_1/accept/activeSet-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/admission-revoked.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/admission-superseded.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/admission-suspended.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/admissionRecord-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/available-catalog-pins-semantic-documents.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/boundAttestation-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/build-lock-complete.json +9 -0
- package/assets/vectors/dsg.organization.release_1/accept/catalog-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/dependencyLock-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/import-pending.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/import-refused.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/import-staged.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/import-verified.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/memberObservation-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/organizationBuild-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/organizationRelease-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/refused-admission-without-invented-approval.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/releaseEligibility-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/releaseStatusObservation-valid.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/resolved-typed-dependency-closure.json +8 -0
- package/assets/vectors/dsg.organization.release_1/accept/retired-release-remains-executable-in-current-active-set.json +9 -0
- package/assets/vectors/dsg.organization.release_1/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/activation-requires-authority.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/admission-requires-decision-authority.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/available-catalog-cannot-carry-unavailable-reason.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-cannot-contain-attestation.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-cannot-contain-authority.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-cannot-self-reference.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-lock-extra-entry.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-lock-mismatched-entry.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-lock-omitted-entry.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/build-lock-reordered-entries.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/catalog-rejects-mismatched-active-set.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/duplicate-release-member-id.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/lock-cannot-contain-unreachable-entry.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/lock-cannot-have-dependency-cycle.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/lock-cannot-omit-transitive-member.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/lock-requires-deterministic-entry-order.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/negative-member-needs-reason.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/pending-import-cannot-carry-terminal-disposition.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/ready-member-needs-evidence.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/refused-admission-cannot-approve-use.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/release-requires-exact-member-subject.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/release-status-is-separate-observation.json +8 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-needs-current-active-set.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-refuses-new-activate.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-refuses-new-admit.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-refuses-new-import.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-refuses-new-resolve.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/retired-release-refuses-new-select.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/revoked-release-refuses-existing-execution.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/stale-trust-view-cannot-restore-release.json +9 -0
- package/assets/vectors/dsg.organization.release_1/reject/verified-import-cannot-be-missing.json +8 -0
- package/assets/vectors/dsg.organization.source_2/accept/organization-minimal.json +7 -0
- package/assets/vectors/dsg.organization.source_2/reject/organization-authority-field.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-capabilitySelection.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-dependencyLock.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-organization.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-profile.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-project.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-releaseDeclaration.json +8 -0
- package/assets/vectors/dsg.organization.source_3/accept/source-releaseMember.json +8 -0
- package/assets/vectors/dsg.organization.source_3/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.organization.source_3/reject/overlay-path-cannot-escape.json +8 -0
- package/assets/vectors/dsg.organization.source_3/reject/source-cannot-grant-authority.json +8 -0
- package/assets/vectors/dsg.organization.source_3/reject/source-members-use-paths.json +8 -0
- package/assets/vectors/dsg.run.execution-binding_1/accept/authorization-allows-unexpired-idempotent-replay.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/accept/authorization-binds-consumed-lease.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/accept/binding-separates-metadata-and-executable.json +8 -0
- package/assets/vectors/dsg.run.execution-binding_1/accept/provider-uses-platform-manifest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/archive-digest-cannot-replace-executable-manifest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-expired-checked-time.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-jointly-altered-generation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-accepted-generation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-case.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-envelope.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-generation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-law.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-operation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/authorization-rejects-wrong-reservation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/binding-requires-provider-manifest-digest.json +8 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/config-digest-cannot-replace-executable-manifest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-cross-workflow-catalog.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-gpu-seconds-over-class.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-installation-mismatch.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-missing-execute-approval.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-non-execute-eligibility.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-parallelism-over-class.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-refused-admission.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-release-mismatch.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-revoked-eligibility.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-run-seconds-over-class.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-stale-trust-view.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-wrong-active-set.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-wrong-admission.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-wrong-execute-binding.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-wrong-inline-digest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/envelope-rejects-wrong-selection.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/index-digest-cannot-replace-executable-manifest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/job-class-cannot-substitute-artifact.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/metadata-bytes-must-match-reference.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/metadata-digest-cannot-replace-executable-manifest.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/operation-binding-rejects-wrong-operation.json +9 -0
- package/assets/vectors/dsg.run.execution-binding_1/reject/operation-binding-rejects-wrong-target.json +9 -0
- package/assets/vectors/dsg.run.job-class_1/accept/class-pins-one-way-artifact-binding.json +8 -0
- package/assets/vectors/dsg.run.job-class_1/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.run.job-class_1/reject/class-requires-exact-artifact.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/accept/archive-hash-is-detached-provenance.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/accept/oci-metadata-types-digest-roles.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/accept/single-platform-image-without-index.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/digest/canonical-envelope.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/archive-hash-is-not-semantic-executable-field.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/artifact-cannot-refer-back-to-class.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/digest-bearing-repository.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/index-media-type-cannot-be-executable-manifest.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/malformed-repository.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/missing-repository.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/scheme-bearing-repository.json +8 -0
- package/assets/vectors/dsg.run.workload-artifact_1/reject/tag-bearing-repository.json +8 -0
- package/checklist.json +8 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{reference-adapter-DDCyFCeV.mjs → reference-adapter-BJ-RkYd3.mjs} +253 -3
- package/dist/reference-adapter-BJ-RkYd3.mjs.map +1 -0
- package/dist/{reference-adapter-B9dycZns.cjs → reference-adapter-C6kR4r8N.cjs} +250 -0
- package/package.json +2 -2
- package/src/reference-adapter.ts +2 -0
- package/src/release-semantics.ts +488 -0
- package/dist/reference-adapter-DDCyFCeV.mjs.map +0 -1
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { createHash, createPublicKey, verify } from "node:crypto";
|
|
2
|
+
import { type Static, type TSchema } from "@sinclair/typebox";
|
|
3
|
+
import { Value } from "@sinclair/typebox/value";
|
|
4
|
+
import { jcsStringify } from "@dynamicalsystems/orn-schemas";
|
|
5
|
+
import {
|
|
6
|
+
closed,
|
|
7
|
+
Reference,
|
|
8
|
+
DependencyLockSchema,
|
|
9
|
+
ExtensionReleaseSchema,
|
|
10
|
+
OrganizationBuildSchema,
|
|
11
|
+
OrganizationReleaseSchema,
|
|
12
|
+
AdmissionRecordSchema,
|
|
13
|
+
ActiveSetSchema,
|
|
14
|
+
CatalogSchema,
|
|
15
|
+
ReleaseEligibilitySchema,
|
|
16
|
+
ExecutionRequestEnvelopeSchema,
|
|
17
|
+
ExtensionReleaseSignatureSchema,
|
|
18
|
+
DispatchLeaseSchema,
|
|
19
|
+
AcceptedSchema,
|
|
20
|
+
UtcSecond,
|
|
21
|
+
} from "@dynamicalsystems/idl";
|
|
22
|
+
import type { Adapter, ParseResult } from "./adapter.js";
|
|
23
|
+
|
|
24
|
+
function digest<T extends object>(value: T): string {
|
|
25
|
+
return createHash("sha256").update(jcsStringify(value)).digest("hex");
|
|
26
|
+
}
|
|
27
|
+
function same(a: Static<typeof Reference>, b: Static<typeof Reference>): boolean {
|
|
28
|
+
return a.orn === b.orn && a.sha256 === b.sha256;
|
|
29
|
+
}
|
|
30
|
+
function unique(values: readonly string[]): boolean {
|
|
31
|
+
return new Set(values).size === values.length;
|
|
32
|
+
}
|
|
33
|
+
function ordered(values: readonly string[]): boolean {
|
|
34
|
+
return values.every((value, index) => index === 0 || values[index - 1]! < value);
|
|
35
|
+
}
|
|
36
|
+
function graphError(
|
|
37
|
+
entries: readonly { id: string; dependsOn: string[] }[],
|
|
38
|
+
roots: readonly string[],
|
|
39
|
+
): string | undefined {
|
|
40
|
+
if (!unique(entries.map((entry) => entry.id))) return "duplicate-member-id";
|
|
41
|
+
const byId = new Map(entries.map((entry) => [entry.id, entry]));
|
|
42
|
+
const visiting = new Set<string>();
|
|
43
|
+
const visited = new Set<string>();
|
|
44
|
+
function visit(id: string): string | undefined {
|
|
45
|
+
if (visiting.has(id)) return "dependency-cycle";
|
|
46
|
+
if (visited.has(id)) return;
|
|
47
|
+
const entry = byId.get(id);
|
|
48
|
+
if (!entry) return "unresolved-dependency";
|
|
49
|
+
visiting.add(id);
|
|
50
|
+
for (const dependency of entry.dependsOn) {
|
|
51
|
+
const error = visit(dependency);
|
|
52
|
+
if (error) return error;
|
|
53
|
+
}
|
|
54
|
+
visiting.delete(id);
|
|
55
|
+
visited.add(id);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const root of roots) {
|
|
59
|
+
const error = visit(root);
|
|
60
|
+
if (error) return error;
|
|
61
|
+
}
|
|
62
|
+
return visited.size === entries.length ? undefined : "extraneous-lock-entry";
|
|
63
|
+
}
|
|
64
|
+
function parse<T extends TSchema>(
|
|
65
|
+
schema: T,
|
|
66
|
+
refine: (value: Static<T>) => string | undefined,
|
|
67
|
+
): (bytes: Uint8Array) => ParseResult {
|
|
68
|
+
return (bytes) => {
|
|
69
|
+
let value: unknown;
|
|
70
|
+
try {
|
|
71
|
+
value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return { ok: false, reason: `not UTF-8 JSON: ${String(error)}` };
|
|
74
|
+
}
|
|
75
|
+
if (!Value.Check(schema, value)) {
|
|
76
|
+
const error = Value.Errors(schema, value).First();
|
|
77
|
+
return { ok: false, reason: `${error?.path ?? ""}: ${error?.message ?? "schema mismatch"}` };
|
|
78
|
+
}
|
|
79
|
+
const error = refine(value);
|
|
80
|
+
return error ? { ok: false, reason: error } : { ok: true };
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// These contexts are vector inputs, not new authority records or provider APIs.
|
|
85
|
+
// Consumers run them against their real verifier through the semantic adapter.
|
|
86
|
+
const ExecutionIdentityContext = ExecutionRequestEnvelopeSchema;
|
|
87
|
+
const ExecutionAuthorizationContext = closed({
|
|
88
|
+
request: ExecutionRequestEnvelopeSchema,
|
|
89
|
+
lease: DispatchLeaseSchema,
|
|
90
|
+
accepted: AcceptedSchema,
|
|
91
|
+
checkedAt: UtcSecond,
|
|
92
|
+
});
|
|
93
|
+
const ReleaseSignatureContext = closed({
|
|
94
|
+
release: ExtensionReleaseSchema,
|
|
95
|
+
signature: ExtensionReleaseSignatureSchema,
|
|
96
|
+
});
|
|
97
|
+
const OrganizationBuildContext = closed({
|
|
98
|
+
build: OrganizationBuildSchema,
|
|
99
|
+
dependencyLock: DependencyLockSchema,
|
|
100
|
+
});
|
|
101
|
+
const ReleaseEligibilityContext = closed({
|
|
102
|
+
eligibility: ReleaseEligibilitySchema,
|
|
103
|
+
currentActiveSet: Reference,
|
|
104
|
+
activeSet: ActiveSetSchema,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export function releaseSemanticAdapters(): Adapter {
|
|
108
|
+
return {
|
|
109
|
+
"dsg.organization.release/1#dependencyLock": parse(DependencyLockSchema, (lock) => {
|
|
110
|
+
if (!ordered(lock.roots) || !ordered(lock.entries.map((entry) => entry.id)))
|
|
111
|
+
return "unsorted-lock";
|
|
112
|
+
for (const entry of lock.entries) {
|
|
113
|
+
if (!ordered(entry.dependsOn) || !ordered(entry.selectedMemberIds)) return "unsorted-lock";
|
|
114
|
+
if (
|
|
115
|
+
entry.kind === "extension-release" &&
|
|
116
|
+
!entry.reference.orn.startsWith("orn:dsg.core.extension.release:")
|
|
117
|
+
)
|
|
118
|
+
return "wrong-release-space";
|
|
119
|
+
if (
|
|
120
|
+
entry.kind === "workload-artifact" &&
|
|
121
|
+
!entry.reference.orn.startsWith("orn:dsg.core.extension.workload-artifact:")
|
|
122
|
+
)
|
|
123
|
+
return "wrong-artifact-space";
|
|
124
|
+
}
|
|
125
|
+
return graphError(lock.entries, lock.roots);
|
|
126
|
+
}),
|
|
127
|
+
"dsg.extension.release/1#semantic.signatureBinding": parse(
|
|
128
|
+
ReleaseSignatureContext,
|
|
129
|
+
({ release, signature }) => {
|
|
130
|
+
const bodySha256 = digest(release);
|
|
131
|
+
if (signature.bodySha256 !== bodySha256 || signature.release.sha256 !== bodySha256)
|
|
132
|
+
return "signature-body-digest-mismatch";
|
|
133
|
+
if (
|
|
134
|
+
signature.release.orn !== release.releaseOrn ||
|
|
135
|
+
signature.publisher !== release.publisher
|
|
136
|
+
)
|
|
137
|
+
return "signature-identity-mismatch";
|
|
138
|
+
try {
|
|
139
|
+
const publicKey = createPublicKey({
|
|
140
|
+
key: Buffer.concat([
|
|
141
|
+
Buffer.from("302a300506032b6570032100", "hex"),
|
|
142
|
+
Buffer.from(signature.publicKey, "hex"),
|
|
143
|
+
]),
|
|
144
|
+
format: "der",
|
|
145
|
+
type: "spki",
|
|
146
|
+
});
|
|
147
|
+
if (
|
|
148
|
+
!verify(
|
|
149
|
+
null,
|
|
150
|
+
Buffer.from(jcsStringify(release), "utf8"),
|
|
151
|
+
publicKey,
|
|
152
|
+
Buffer.from(signature.signature, "hex"),
|
|
153
|
+
)
|
|
154
|
+
)
|
|
155
|
+
return "invalid-release-signature";
|
|
156
|
+
} catch {
|
|
157
|
+
return "invalid-release-signature";
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
},
|
|
161
|
+
),
|
|
162
|
+
"dsg.extension.release/1#release": parse(ExtensionReleaseSchema, (release) => {
|
|
163
|
+
if (
|
|
164
|
+
release.releaseOrn !==
|
|
165
|
+
`orn:dsg.core.extension.release:${release.namespace}/${release.name}@${release.version}`
|
|
166
|
+
)
|
|
167
|
+
return "release-name-mismatch";
|
|
168
|
+
if (!unique(release.dependencies.map((dependency) => dependency.id)))
|
|
169
|
+
return "duplicate-dependency-id";
|
|
170
|
+
const error = graphError(
|
|
171
|
+
release.components,
|
|
172
|
+
release.components.map((component) => component.id),
|
|
173
|
+
);
|
|
174
|
+
if (error) return error;
|
|
175
|
+
const kinds = new Set(release.components.map((component) => component.kind));
|
|
176
|
+
if (release.compute && (!kinds.has("job-class") || !kinds.has("workload-artifact")))
|
|
177
|
+
return "missing-compute-component";
|
|
178
|
+
for (const component of release.components) {
|
|
179
|
+
if (
|
|
180
|
+
component.kind === "workload-artifact" &&
|
|
181
|
+
!component.reference.orn.startsWith("orn:dsg.core.extension.workload-artifact:")
|
|
182
|
+
)
|
|
183
|
+
return "wrong-artifact-space";
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}),
|
|
187
|
+
"dsg.organization.release/1#organizationBuild": parse(OrganizationBuildSchema, (build) => {
|
|
188
|
+
const orderedBy = <T>(values: readonly T[], key: (value: T) => string): boolean =>
|
|
189
|
+
ordered(values.map(key));
|
|
190
|
+
if (!orderedBy(build.sourceDocuments, (document) => document.path))
|
|
191
|
+
return "unsorted-source-closure";
|
|
192
|
+
if (
|
|
193
|
+
!orderedBy(build.projects, (project) => project.id) ||
|
|
194
|
+
!orderedBy(build.selections, (selection) => selection.id) ||
|
|
195
|
+
build.selections.some(
|
|
196
|
+
(selection) => !orderedBy(selection.members, (member) => member.id),
|
|
197
|
+
) ||
|
|
198
|
+
!orderedBy(build.components, (component) =>
|
|
199
|
+
[
|
|
200
|
+
component.extensionRelease.orn,
|
|
201
|
+
component.extensionRelease.sha256,
|
|
202
|
+
component.memberId,
|
|
203
|
+
].join("\0"),
|
|
204
|
+
) ||
|
|
205
|
+
!orderedBy(build.typedReleases, (release) => release.id) ||
|
|
206
|
+
!orderedBy(build.instructions, (reference) => `${reference.orn}\0${reference.sha256}`) ||
|
|
207
|
+
!orderedBy(build.handling, (reference) => `${reference.orn}\0${reference.sha256}`) ||
|
|
208
|
+
!orderedBy(
|
|
209
|
+
build.releaseDeclarations,
|
|
210
|
+
(reference) => `${reference.orn}\0${reference.sha256}`,
|
|
211
|
+
) ||
|
|
212
|
+
!orderedBy(build.releaseMembers, (member) => member.id)
|
|
213
|
+
)
|
|
214
|
+
return "unsorted-build";
|
|
215
|
+
if (
|
|
216
|
+
!unique(build.projects.map((project) => project.id)) ||
|
|
217
|
+
!unique(build.selections.map((selection) => selection.id)) ||
|
|
218
|
+
!unique(build.releaseMembers.map((member) => member.id))
|
|
219
|
+
)
|
|
220
|
+
return "duplicate-member-id";
|
|
221
|
+
const components = new Map<string, (typeof build.components)[number]>();
|
|
222
|
+
for (const component of build.components) {
|
|
223
|
+
const key = `${component.extensionRelease.orn}\0${component.extensionRelease.sha256}\0${component.memberId}`;
|
|
224
|
+
if (components.has(key)) return "duplicate-component-id";
|
|
225
|
+
components.set(key, component);
|
|
226
|
+
}
|
|
227
|
+
for (const selection of build.selections) {
|
|
228
|
+
if (!unique(selection.members.map((member) => member.id))) return "duplicate-member-id";
|
|
229
|
+
for (const member of selection.members) {
|
|
230
|
+
const component = components.get(
|
|
231
|
+
`${selection.extensionRelease.orn}\0${selection.extensionRelease.sha256}\0${member.id}`,
|
|
232
|
+
);
|
|
233
|
+
if (
|
|
234
|
+
!component ||
|
|
235
|
+
component.kind !== member.kind ||
|
|
236
|
+
!same(component.reference, member.reference)
|
|
237
|
+
)
|
|
238
|
+
return "selected-component-mismatch";
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}),
|
|
243
|
+
"dsg.organization.release/1#semantic.organizationBuild": parse(
|
|
244
|
+
OrganizationBuildContext,
|
|
245
|
+
({ build, dependencyLock }) => {
|
|
246
|
+
if (build.dependencyLock.sha256 !== digest(dependencyLock))
|
|
247
|
+
return "dependency-lock-digest-mismatch";
|
|
248
|
+
if (jcsStringify(build.typedReleases) !== jcsStringify(dependencyLock.entries))
|
|
249
|
+
return "typed-release-lock-mismatch";
|
|
250
|
+
return;
|
|
251
|
+
},
|
|
252
|
+
),
|
|
253
|
+
"dsg.organization.release/1#organizationRelease": parse(OrganizationReleaseSchema, (release) =>
|
|
254
|
+
unique(release.members.map((member) => member.id)) ? undefined : "duplicate-member-id",
|
|
255
|
+
),
|
|
256
|
+
"dsg.organization.release/1#admissionRecord": parse(AdmissionRecordSchema, (admission) => {
|
|
257
|
+
if (!unique(admission.components.map((component) => component.id)))
|
|
258
|
+
return "duplicate-member-id";
|
|
259
|
+
if (admission.status === "admitted" && !unique(admission.approvedUses.map((use) => use.use)))
|
|
260
|
+
return "duplicate-approved-use";
|
|
261
|
+
return;
|
|
262
|
+
}),
|
|
263
|
+
"dsg.organization.release/1#activeSet": parse(ActiveSetSchema, (activeSet) => {
|
|
264
|
+
if (!unique(activeSet.members.map((member) => `${member.selectionId}\0${member.memberId}`)))
|
|
265
|
+
return "duplicate-active-member";
|
|
266
|
+
for (const member of activeSet.members) {
|
|
267
|
+
if (!unique(member.components.map((component) => component.id)))
|
|
268
|
+
return "duplicate-member-id";
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}),
|
|
272
|
+
"dsg.organization.release/1#catalog": parse(CatalogSchema, (catalog) => {
|
|
273
|
+
if (!unique(catalog.entries.map((entry) => entry.id))) return "duplicate-catalog-entry";
|
|
274
|
+
for (const entry of catalog.entries) {
|
|
275
|
+
if (!same(entry.activeSet, catalog.activeSet)) return "catalog-active-set-mismatch";
|
|
276
|
+
if ((entry.jobClass === null) !== (entry.workloadArtifact === null))
|
|
277
|
+
return "incomplete-compute-provenance";
|
|
278
|
+
}
|
|
279
|
+
return;
|
|
280
|
+
}),
|
|
281
|
+
"dsg.organization.release/1#releaseEligibility": parse(
|
|
282
|
+
ReleaseEligibilitySchema,
|
|
283
|
+
(eligibility) => {
|
|
284
|
+
if (!same(eligibility.release, eligibility.observation.subject))
|
|
285
|
+
return "status-subject-mismatch";
|
|
286
|
+
if (!same(eligibility.trustView, eligibility.observation.trustView))
|
|
287
|
+
return "stale-trust-view";
|
|
288
|
+
if (eligibility.observation.status === "revoked") return "release-revoked";
|
|
289
|
+
if (
|
|
290
|
+
eligibility.observation.status === "retired" &&
|
|
291
|
+
(eligibility.operation !== "execute" || eligibility.activeSet === null)
|
|
292
|
+
)
|
|
293
|
+
return "release-retired";
|
|
294
|
+
return;
|
|
295
|
+
},
|
|
296
|
+
),
|
|
297
|
+
"dsg.organization.release/1#semantic.releaseEligibility": parse(
|
|
298
|
+
ReleaseEligibilityContext,
|
|
299
|
+
({ eligibility, currentActiveSet, activeSet }) => {
|
|
300
|
+
if (!same(eligibility.release, eligibility.observation.subject))
|
|
301
|
+
return "status-subject-mismatch";
|
|
302
|
+
if (!same(eligibility.trustView, eligibility.observation.trustView))
|
|
303
|
+
return "stale-trust-view";
|
|
304
|
+
if (eligibility.observation.status === "revoked") return "release-revoked";
|
|
305
|
+
if (eligibility.observation.status !== "retired") return;
|
|
306
|
+
if (eligibility.operation !== "execute" || eligibility.activeSet === null)
|
|
307
|
+
return "release-retired";
|
|
308
|
+
if (
|
|
309
|
+
!same(eligibility.activeSet, currentActiveSet) ||
|
|
310
|
+
currentActiveSet.sha256 !== digest(activeSet)
|
|
311
|
+
)
|
|
312
|
+
return "inactive-set";
|
|
313
|
+
if (!activeSet.members.some((member) => same(member.extensionRelease, eligibility.release)))
|
|
314
|
+
return "release-not-active";
|
|
315
|
+
return;
|
|
316
|
+
},
|
|
317
|
+
),
|
|
318
|
+
"dsg.run.execution-binding/1#semantic.executionAuthorization": parse(
|
|
319
|
+
ExecutionAuthorizationContext,
|
|
320
|
+
({ request, lease, accepted, checkedAt }) => {
|
|
321
|
+
if (accepted.generation !== request.operation.expectedGeneration + 1)
|
|
322
|
+
return "accepted-generation-mismatch";
|
|
323
|
+
if (accepted.operationId !== request.operation.operationId)
|
|
324
|
+
return "accepted-operation-mismatch";
|
|
325
|
+
if (accepted.planDigest !== request.operation.planDigest) return "accepted-plan-mismatch";
|
|
326
|
+
const { operation, binding } = request;
|
|
327
|
+
if (!same(binding.reservation, operation.reservation))
|
|
328
|
+
return "binding-reservation-mismatch";
|
|
329
|
+
if (lease.operationId !== operation.operationId) return "lease-operation-mismatch";
|
|
330
|
+
if (lease.generation !== accepted.generation) return "lease-generation-mismatch";
|
|
331
|
+
if (lease.caseOrn !== operation.case.orn) return "lease-case-mismatch";
|
|
332
|
+
if (lease.envelopeSha256 !== digest(operation)) return "lease-envelope-mismatch";
|
|
333
|
+
if (lease.lawSha256 !== operation.document.law.bundle.sha256) return "lease-law-mismatch";
|
|
334
|
+
if (!same(lease.reservation, binding.reservation)) return "lease-reservation-mismatch";
|
|
335
|
+
if (Date.parse(lease.expiresAt) <= Date.parse(lease.consumedAt))
|
|
336
|
+
return "invalid-dispatch-lease-window";
|
|
337
|
+
if (Date.parse(checkedAt) >= Date.parse(lease.expiresAt)) return "expired-dispatch-lease";
|
|
338
|
+
return;
|
|
339
|
+
},
|
|
340
|
+
),
|
|
341
|
+
"dsg.run.execution-binding/1#semantic.executionIdentity": parse(
|
|
342
|
+
ExecutionIdentityContext,
|
|
343
|
+
({
|
|
344
|
+
binding,
|
|
345
|
+
operation,
|
|
346
|
+
jobClass,
|
|
347
|
+
workloadArtifact: artifact,
|
|
348
|
+
workloadArtifactProvenance: provenance,
|
|
349
|
+
admission,
|
|
350
|
+
activeSet,
|
|
351
|
+
releaseEligibility,
|
|
352
|
+
selection,
|
|
353
|
+
catalogEntry,
|
|
354
|
+
}) => {
|
|
355
|
+
if (releaseEligibility.operation !== "execute") return "eligibility-operation-mismatch";
|
|
356
|
+
if (releaseEligibility.observation.status === "revoked") return "release-revoked";
|
|
357
|
+
if (!same(releaseEligibility.observation.subject, releaseEligibility.release))
|
|
358
|
+
return "eligibility-subject-mismatch";
|
|
359
|
+
if (!same(releaseEligibility.observation.trustView, releaseEligibility.trustView))
|
|
360
|
+
return "eligibility-observation-trust-mismatch";
|
|
361
|
+
if (
|
|
362
|
+
releaseEligibility.observation.status === "retired" &&
|
|
363
|
+
(releaseEligibility.operation !== "execute" ||
|
|
364
|
+
releaseEligibility.activeSet === null ||
|
|
365
|
+
!same(releaseEligibility.activeSet, binding.activeSet))
|
|
366
|
+
)
|
|
367
|
+
return "release-retired";
|
|
368
|
+
if (binding.selection.sha256 !== digest(selection)) return "selection-digest-mismatch";
|
|
369
|
+
if (selection.id !== catalogEntry.selectionId || selection.id !== admission.selectionId)
|
|
370
|
+
return "selection-id-mismatch";
|
|
371
|
+
if (
|
|
372
|
+
!same(selection.extensionRelease, binding.extensionRelease) ||
|
|
373
|
+
!same(catalogEntry.extensionRelease, binding.extensionRelease)
|
|
374
|
+
)
|
|
375
|
+
return "selection-release-mismatch";
|
|
376
|
+
if (catalogEntry.availability !== "available") return "catalog-entry-unavailable";
|
|
377
|
+
if (
|
|
378
|
+
!same(catalogEntry.activeSet, binding.activeSet) ||
|
|
379
|
+
!same(catalogEntry.workflow, binding.workflow) ||
|
|
380
|
+
catalogEntry.jobClass === null ||
|
|
381
|
+
!same(catalogEntry.jobClass, binding.jobClass) ||
|
|
382
|
+
catalogEntry.workloadArtifact === null ||
|
|
383
|
+
!same(catalogEntry.workloadArtifact, binding.workloadArtifact)
|
|
384
|
+
)
|
|
385
|
+
return "catalog-binding-mismatch";
|
|
386
|
+
if (!same(releaseEligibility.release, binding.extensionRelease))
|
|
387
|
+
return "eligibility-release-mismatch";
|
|
388
|
+
if (!same(releaseEligibility.trustView, binding.trustView))
|
|
389
|
+
return "eligibility-trust-view-mismatch";
|
|
390
|
+
if (
|
|
391
|
+
releaseEligibility.activeSet === null ||
|
|
392
|
+
!same(releaseEligibility.activeSet, binding.activeSet)
|
|
393
|
+
)
|
|
394
|
+
return "eligibility-active-set-mismatch";
|
|
395
|
+
if (admission.status !== "admitted") return "admission-refused";
|
|
396
|
+
if (
|
|
397
|
+
!admission.approvedUses.some(
|
|
398
|
+
(approved) => approved.use === "execute" && same(approved.binding, binding.jobClass),
|
|
399
|
+
)
|
|
400
|
+
)
|
|
401
|
+
return "execution-use-not-approved";
|
|
402
|
+
if (operation.document.resources.maxRunSeconds > jobClass.bounds.maxRunSeconds)
|
|
403
|
+
return "run-seconds-exceed-class";
|
|
404
|
+
if (operation.document.resources.maxGpuSeconds > jobClass.bounds.maxGpuSeconds)
|
|
405
|
+
return "gpu-seconds-exceed-class";
|
|
406
|
+
if (operation.document.resources.maxParallelism > jobClass.bounds.maxParallelism)
|
|
407
|
+
return "parallelism-exceeds-class";
|
|
408
|
+
if (binding.admission.sha256 !== digest(admission)) return "admission-digest-mismatch";
|
|
409
|
+
if (binding.activeSet.sha256 !== digest(activeSet)) return "active-set-digest-mismatch";
|
|
410
|
+
if (
|
|
411
|
+
binding.installation !== admission.installation ||
|
|
412
|
+
binding.installation !== activeSet.installation
|
|
413
|
+
)
|
|
414
|
+
return "installation-mismatch";
|
|
415
|
+
if (
|
|
416
|
+
!same(binding.organizationBuild, admission.build) ||
|
|
417
|
+
!same(binding.organizationBuild, activeSet.build)
|
|
418
|
+
)
|
|
419
|
+
return "organization-build-mismatch";
|
|
420
|
+
if (
|
|
421
|
+
!same(binding.organizationRelease, admission.release) ||
|
|
422
|
+
!same(binding.organizationRelease, activeSet.release)
|
|
423
|
+
)
|
|
424
|
+
return "organization-release-mismatch";
|
|
425
|
+
if (!same(binding.extensionRelease, admission.extensionRelease))
|
|
426
|
+
return "admission-release-mismatch";
|
|
427
|
+
const activeMember = activeSet.members.find(
|
|
428
|
+
(member) =>
|
|
429
|
+
same(member.admission, binding.admission) &&
|
|
430
|
+
same(member.extensionRelease, binding.extensionRelease),
|
|
431
|
+
);
|
|
432
|
+
if (!activeMember) return "release-not-active";
|
|
433
|
+
if (
|
|
434
|
+
activeMember.selectionId !== selection.id ||
|
|
435
|
+
activeMember.memberId !== catalogEntry.memberId
|
|
436
|
+
)
|
|
437
|
+
return "active-member-identity-mismatch";
|
|
438
|
+
const selectedComponents = selection.members.map((component) => component.reference);
|
|
439
|
+
const activeComponents = activeMember.components.map((component) => component.reference);
|
|
440
|
+
const admittedComponents = admission.components.map((component) => component.reference);
|
|
441
|
+
for (const required of [
|
|
442
|
+
binding.workflow,
|
|
443
|
+
binding.jobClass,
|
|
444
|
+
binding.workloadArtifact,
|
|
445
|
+
binding.eventCatalog,
|
|
446
|
+
]) {
|
|
447
|
+
if (!selectedComponents.some((component) => same(component, required)))
|
|
448
|
+
return "selected-component-mismatch";
|
|
449
|
+
if (!activeComponents.some((component) => same(component, required)))
|
|
450
|
+
return "active-component-mismatch";
|
|
451
|
+
if (!admittedComponents.some((component) => same(component, required)))
|
|
452
|
+
return "admitted-component-mismatch";
|
|
453
|
+
}
|
|
454
|
+
if (binding.operation.sha256 !== digest(operation)) return "operation-digest-mismatch";
|
|
455
|
+
if (!same(binding.target, operation.document.placement)) return "operation-target-mismatch";
|
|
456
|
+
if (!same(binding.jobClass, operation.document.classContract))
|
|
457
|
+
return "operation-job-class-mismatch";
|
|
458
|
+
if (!same(binding.workloadArtifact, operation.document.workload))
|
|
459
|
+
return "operation-workload-mismatch";
|
|
460
|
+
if (!same(binding.law, operation.document.law.bundle)) return "operation-law-mismatch";
|
|
461
|
+
if (binding.workloadArtifact.sha256 !== digest(artifact))
|
|
462
|
+
return "artifact-metadata-digest-mismatch";
|
|
463
|
+
if (binding.jobClass.sha256 !== digest(jobClass)) return "job-class-digest-mismatch";
|
|
464
|
+
if (!same(jobClass.workloadArtifact, binding.workloadArtifact))
|
|
465
|
+
return "job-class-artifact-mismatch";
|
|
466
|
+
if (!same(jobClass.eventCatalog, binding.eventCatalog)) return "event-catalog-mismatch";
|
|
467
|
+
if (!same(provenance.artifact, binding.workloadArtifact))
|
|
468
|
+
return "provenance-subject-mismatch";
|
|
469
|
+
if (jcsStringify(provenance.source) !== jcsStringify(artifact.source))
|
|
470
|
+
return "source-provenance-mismatch";
|
|
471
|
+
if (binding.executableManifestSha256 !== artifact.executable.manifest.sha256)
|
|
472
|
+
return "wrong-executable-digest-role";
|
|
473
|
+
if (
|
|
474
|
+
artifact.executable.platform.os !== "linux" ||
|
|
475
|
+
artifact.executable.platform.architecture !== "amd64"
|
|
476
|
+
)
|
|
477
|
+
return "unsupported-executable-platform";
|
|
478
|
+
if (
|
|
479
|
+
!jobClass.platforms.includes(
|
|
480
|
+
`${artifact.executable.platform.os}/${artifact.executable.platform.architecture}`,
|
|
481
|
+
)
|
|
482
|
+
)
|
|
483
|
+
return "job-class-platform-mismatch";
|
|
484
|
+
return;
|
|
485
|
+
},
|
|
486
|
+
),
|
|
487
|
+
};
|
|
488
|
+
}
|