@dynamicalsystems/idl 0.6.1
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/LICENSE +191 -0
- package/dist/index.cjs +692 -0
- package/dist/index.d.cts +672 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +672 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +646 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
- package/schema/dsg-infra-adoption-fact-v1.json +74 -0
- package/schema/dsg-infra-resource-descriptor-v1.json +127 -0
- package/schema/dsg-infra-signed-law-v1.json +1012 -0
- package/schema/dsg-kernel-bootstrap-v1.json +278 -0
- package/schema/dsg-kernel-dispatch-consume-v1.json +205 -0
- package/schema/dsg-kernel-ordinary-authority-v1.json +151 -0
- package/schema/dsg-registry-revocations-v1.json +207 -0
- package/schema/dsg-run-operation-v1.json +471 -0
- package/src/index.ts +110 -0
- package/src/infra/adoption-fact.v1.ts +47 -0
- package/src/infra/resource-descriptor.v1.ts +58 -0
- package/src/infra/signed-law.v1.ts +277 -0
- package/src/kernel/bootstrap.v1.ts +68 -0
- package/src/kernel/dispatch-consume.v1.ts +114 -0
- package/src/kernel/ordinary-authority.v1.ts +53 -0
- package/src/primitives.ts +49 -0
- package/src/registry/revocations.v1.ts +87 -0
- package/src/run/contract-versions.ts +13 -0
- package/src/run/operation.v1.ts +158 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export { closed, Hex64, NonEmptyString, Orn, Reference, SafeInt, UtcSecond } from "./primitives.js";
|
|
2
|
+
export type { ProfileEntry } from "./primitives.js";
|
|
3
|
+
export {
|
|
4
|
+
DISPATCH_CONSUME_PROFILE,
|
|
5
|
+
DISPATCH_MAX_SKEW_SECONDS,
|
|
6
|
+
DispatchConsumeRequestSchema,
|
|
7
|
+
DispatchLeaseSchema,
|
|
8
|
+
DispatchRefusalCodeSchema,
|
|
9
|
+
DispatchRefusalSchema,
|
|
10
|
+
} from "./kernel/dispatch-consume.v1.js";
|
|
11
|
+
export type {
|
|
12
|
+
DispatchConsumeRequest,
|
|
13
|
+
DispatchLease,
|
|
14
|
+
DispatchRefusal,
|
|
15
|
+
DispatchRefusalCode,
|
|
16
|
+
} from "./kernel/dispatch-consume.v1.js";
|
|
17
|
+
export {
|
|
18
|
+
AcceptedSchema,
|
|
19
|
+
ExecutionDocumentSchema,
|
|
20
|
+
ExecutionLawSchema,
|
|
21
|
+
ExecutionResourcesSchema,
|
|
22
|
+
OPERATION_PROFILE,
|
|
23
|
+
OperationBeforeSchema,
|
|
24
|
+
OperationCleanupSchema,
|
|
25
|
+
OperationCostSchema,
|
|
26
|
+
OperationEvidenceSchema,
|
|
27
|
+
OperationExecutionSchema,
|
|
28
|
+
OperationRequestSchema,
|
|
29
|
+
OperationStatusSchema,
|
|
30
|
+
ReadbackSchema,
|
|
31
|
+
} from "./run/operation.v1.js";
|
|
32
|
+
export type {
|
|
33
|
+
Accepted,
|
|
34
|
+
ExecutionDocument,
|
|
35
|
+
ExecutionLaw,
|
|
36
|
+
ExecutionResources,
|
|
37
|
+
OperationBefore,
|
|
38
|
+
OperationCleanup,
|
|
39
|
+
OperationCost,
|
|
40
|
+
OperationEvidence,
|
|
41
|
+
OperationExecution,
|
|
42
|
+
OperationRequest,
|
|
43
|
+
OperationStatus,
|
|
44
|
+
Readback,
|
|
45
|
+
} from "./run/operation.v1.js";
|
|
46
|
+
export {
|
|
47
|
+
PRICE_PROFILE_REFERENCE,
|
|
48
|
+
SCOPE_REFERENCE,
|
|
49
|
+
SIGNED_LAW_DOMAIN,
|
|
50
|
+
SIGNED_LAW_PROFILE,
|
|
51
|
+
SignedLawBundleSchema,
|
|
52
|
+
} from "./infra/signed-law.v1.js";
|
|
53
|
+
export {
|
|
54
|
+
RESOURCE_DESCRIPTOR_KIND,
|
|
55
|
+
RESOURCE_DESCRIPTOR_PROFILE,
|
|
56
|
+
ResourceDescriptorSchema,
|
|
57
|
+
} from "./infra/resource-descriptor.v1.js";
|
|
58
|
+
export type { ResourceDescriptor } from "./infra/resource-descriptor.v1.js";
|
|
59
|
+
export { ADOPTION_FACT_PROFILE, AdoptionFactSchema } from "./infra/adoption-fact.v1.js";
|
|
60
|
+
export type { AdoptionFact } from "./infra/adoption-fact.v1.js";
|
|
61
|
+
export type { SignedLawBundle } from "./infra/signed-law.v1.js";
|
|
62
|
+
export {
|
|
63
|
+
REVOCATIONS_PROFILE,
|
|
64
|
+
RevocationPointerSchema,
|
|
65
|
+
RevocationSchema,
|
|
66
|
+
} from "./registry/revocations.v1.js";
|
|
67
|
+
export type { RevocationPointer, RevocationSnapshot } from "./registry/revocations.v1.js";
|
|
68
|
+
export {
|
|
69
|
+
BOOTSTRAP_PROFILE,
|
|
70
|
+
BootstrapActionSchema,
|
|
71
|
+
BootstrapIntentSchema,
|
|
72
|
+
SignedBootstrapIntentSchema,
|
|
73
|
+
} from "./kernel/bootstrap.v1.js";
|
|
74
|
+
export type {
|
|
75
|
+
BootstrapAction,
|
|
76
|
+
BootstrapIntent,
|
|
77
|
+
SignedBootstrapIntent,
|
|
78
|
+
} from "./kernel/bootstrap.v1.js";
|
|
79
|
+
export {
|
|
80
|
+
ORDINARY_AUTHORITY_PROFILE,
|
|
81
|
+
OrdinaryAuthoritySchema,
|
|
82
|
+
} from "./kernel/ordinary-authority.v1.js";
|
|
83
|
+
export type { OrdinaryAuthority } from "./kernel/ordinary-authority.v1.js";
|
|
84
|
+
export { EXECUTOR_PROTOCOL_VERSION, PROVIDER_PROTOCOL_VERSION } from "./run/contract-versions.js";
|
|
85
|
+
export type { ExecutorProtocolVersion, ProviderProtocolVersion } from "./run/contract-versions.js";
|
|
86
|
+
|
|
87
|
+
import type { ProfileEntry } from "./primitives.js";
|
|
88
|
+
import { dispatchConsumeV1 } from "./kernel/dispatch-consume.v1.js";
|
|
89
|
+
import { operationV1 } from "./run/operation.v1.js";
|
|
90
|
+
import { signedLawV1 } from "./infra/signed-law.v1.js";
|
|
91
|
+
import { resourceDescriptorV1 } from "./infra/resource-descriptor.v1.js";
|
|
92
|
+
import { adoptionFactV1 } from "./infra/adoption-fact.v1.js";
|
|
93
|
+
import { revocationsV1 } from "./registry/revocations.v1.js";
|
|
94
|
+
import { bootstrapV1 } from "./kernel/bootstrap.v1.js";
|
|
95
|
+
import { ordinaryAuthorityV1 } from "./kernel/ordinary-authority.v1.js";
|
|
96
|
+
|
|
97
|
+
/** Every profile this version of the package defines, keyed by literal.
|
|
98
|
+
* Profile modules are added here as they are extracted; the rules test
|
|
99
|
+
* and the schema emitter walk this registry, so a module that is not
|
|
100
|
+
* registered does not exist. */
|
|
101
|
+
export const PROFILES: Readonly<Record<string, ProfileEntry>> = {
|
|
102
|
+
[dispatchConsumeV1.literal]: dispatchConsumeV1,
|
|
103
|
+
[operationV1.literal]: operationV1,
|
|
104
|
+
[signedLawV1.literal]: signedLawV1,
|
|
105
|
+
[resourceDescriptorV1.literal]: resourceDescriptorV1,
|
|
106
|
+
[adoptionFactV1.literal]: adoptionFactV1,
|
|
107
|
+
[revocationsV1.literal]: revocationsV1,
|
|
108
|
+
[bootstrapV1.literal]: bootstrapV1,
|
|
109
|
+
[ordinaryAuthorityV1.literal]: ordinaryAuthorityV1,
|
|
110
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// dsg.infra.adoption-fact/1
|
|
2
|
+
// Owner: dsg-infra (governance/adoption.py is the producer: it verifies an
|
|
3
|
+
// exported kernel bootstrap record snapshot offline - canonical digest,
|
|
4
|
+
// event hash chain, stream heads, artifact bytes - and emits the accepted
|
|
5
|
+
// root-authorizing operation as this fact). The tofu baseline root
|
|
6
|
+
// consumes it and re-validates independently: its deployment-specific
|
|
7
|
+
// conditions (which root string, testOnly false for the real baseline)
|
|
8
|
+
// are that root's own law, deliberately NOT part of this shape - a
|
|
9
|
+
// synthetic testOnly fact is a valid FACT, just never a valid deployed
|
|
10
|
+
// authorization.
|
|
11
|
+
//
|
|
12
|
+
// Lifted from dsg-infra governance/adoption.py at e9d9501 and
|
|
13
|
+
// infrastructure/environments/dsg-run/adoption.tf (S01, commit fccf709).
|
|
14
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
15
|
+
import { closed, Hex64, NonEmptyString, Orn, type ProfileEntry } from "../primitives.js";
|
|
16
|
+
|
|
17
|
+
export const ADOPTION_FACT_PROFILE = "dsg.infra.adoption-fact/1" as const;
|
|
18
|
+
|
|
19
|
+
const AdoptionFactSchemaValue = closed({
|
|
20
|
+
profile: Type.Literal(ADOPTION_FACT_PROFILE),
|
|
21
|
+
/** The root the record names as active baseline owner. */
|
|
22
|
+
root: NonEmptyString,
|
|
23
|
+
lineage: NonEmptyString,
|
|
24
|
+
/** The accepted root-authorizing operation. */
|
|
25
|
+
operation: NonEmptyString,
|
|
26
|
+
/** Count of accepted root operations; ownership needs at least one. */
|
|
27
|
+
generation: Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
|
|
28
|
+
/** Canonical digest of the verified record snapshot. */
|
|
29
|
+
snapshotSha256: Hex64,
|
|
30
|
+
/** initialize establishes the first owner; cutover transfers it. restore
|
|
31
|
+
* and enrollment move custody and human roots, never root ownership. */
|
|
32
|
+
action: Type.Union([
|
|
33
|
+
Type.Literal("initialize_kernel_record"),
|
|
34
|
+
Type.Literal("cutover_single_writer"),
|
|
35
|
+
]),
|
|
36
|
+
signer: Orn,
|
|
37
|
+
humanRoot: NonEmptyString,
|
|
38
|
+
testOnly: Type.Boolean(),
|
|
39
|
+
});
|
|
40
|
+
export const AdoptionFactSchema: typeof AdoptionFactSchemaValue = AdoptionFactSchemaValue;
|
|
41
|
+
export type AdoptionFact = Static<typeof AdoptionFactSchema>;
|
|
42
|
+
|
|
43
|
+
export const adoptionFactV1: ProfileEntry = {
|
|
44
|
+
literal: ADOPTION_FACT_PROFILE,
|
|
45
|
+
rootShape: "fact",
|
|
46
|
+
shapes: { fact: AdoptionFactSchema },
|
|
47
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// dsg.infra.resource-descriptor/1
|
|
2
|
+
// Owner: dsg-infra (policy/resource-descriptor.schema.json is the source;
|
|
3
|
+
// law_contract.py validates this exact shape and evaluate_descriptor
|
|
4
|
+
// returns its canonical digest). A concrete provider-neutral resource: the
|
|
5
|
+
// thing rendered from a workload and gated against the signed law's
|
|
6
|
+
// capability limits before any provider API sees it. Distinct from
|
|
7
|
+
// signed-law's capabilityProfile, which states allowed LIMITS; this
|
|
8
|
+
// document states one concrete resource checked against them.
|
|
9
|
+
//
|
|
10
|
+
// The wire carries kind "dsg.infra.resource-descriptor" plus
|
|
11
|
+
// schemaVersion 1; the /1 literal itself is the version marker signed-law
|
|
12
|
+
// fields pin (scope.resourceDescriptorVersion, capabilities
|
|
13
|
+
// .descriptorVersion), so the constant lives here and signed-law imports
|
|
14
|
+
// it. Lifted verbatim from dsg-infra policy/resource-descriptor.schema.json
|
|
15
|
+
// at fccf709.
|
|
16
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
17
|
+
import { closed, NonEmptyString, type ProfileEntry } from "../primitives.js";
|
|
18
|
+
|
|
19
|
+
export const RESOURCE_DESCRIPTOR_PROFILE = "dsg.infra.resource-descriptor/1" as const;
|
|
20
|
+
/** The document kind: the profile literal without its version suffix; the
|
|
21
|
+
* version rides in schemaVersion. Frozen /1 wire choice. */
|
|
22
|
+
export const RESOURCE_DESCRIPTOR_KIND = "dsg.infra.resource-descriptor" as const;
|
|
23
|
+
|
|
24
|
+
const prefixedDigest = Type.String({ pattern: "^sha256:[0-9a-f]{64}$" });
|
|
25
|
+
|
|
26
|
+
const ResourceDescriptorSchemaValue = closed({
|
|
27
|
+
schemaVersion: Type.Literal(1),
|
|
28
|
+
kind: Type.Literal(RESOURCE_DESCRIPTOR_KIND),
|
|
29
|
+
workloadClass: NonEmptyString,
|
|
30
|
+
lifecycle: Type.Union([Type.Literal("ephemeral"), Type.Literal("durable")]),
|
|
31
|
+
machineType: Type.String({ pattern: "^[a-z][a-z0-9]*-[a-z0-9]+-[0-9]+$" }),
|
|
32
|
+
accelerator: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
33
|
+
acceleratorCount: Type.Integer({ minimum: 0 }),
|
|
34
|
+
vcpuCount: Type.Integer({ minimum: 1 }),
|
|
35
|
+
memoryGiB: Type.Integer({ minimum: 1 }),
|
|
36
|
+
maxRunSeconds: Type.Integer({ minimum: 1 }),
|
|
37
|
+
maxParallelism: Type.Integer({ minimum: 1 }),
|
|
38
|
+
region: NonEmptyString,
|
|
39
|
+
imageDigest: prefixedDigest,
|
|
40
|
+
moduleDigest: prefixedDigest,
|
|
41
|
+
externalIp: Type.Literal(false),
|
|
42
|
+
network: Type.Literal("private"),
|
|
43
|
+
reservation: closed({
|
|
44
|
+
gpuSeconds: Type.Integer({ minimum: 0 }),
|
|
45
|
+
usdMicroUnits: Type.Integer({ minimum: 0 }),
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
export const ResourceDescriptorSchema: typeof ResourceDescriptorSchemaValue =
|
|
49
|
+
ResourceDescriptorSchemaValue;
|
|
50
|
+
export type ResourceDescriptor = Static<typeof ResourceDescriptorSchema>;
|
|
51
|
+
|
|
52
|
+
export const resourceDescriptorV1: ProfileEntry = {
|
|
53
|
+
literal: RESOURCE_DESCRIPTOR_PROFILE,
|
|
54
|
+
literalNote:
|
|
55
|
+
"carried as kind (unversioned) plus schemaVersion on the document; the /1 literal is the version marker signed-law pins",
|
|
56
|
+
rootShape: "descriptor",
|
|
57
|
+
shapes: { descriptor: ResourceDescriptorSchema },
|
|
58
|
+
};
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// dsg.infra.signed-law/1
|
|
2
|
+
// Owner: dsg-infra (the S02 law producer; both prior copies were generated
|
|
3
|
+
// from dsg-infra policy/law-bundle.schema.json, source SHA-256
|
|
4
|
+
// bc3692395cf994567115c76d8fce66a7e9ebe7b2c50c70e1c83b8b10693a838c).
|
|
5
|
+
//
|
|
6
|
+
// The literal is the signing DOMAIN: it appears as the `domain` member of
|
|
7
|
+
// the canonical signature input (JCS of {domain, payload, payloadSha256,
|
|
8
|
+
// testOnly}), not as a field of the bundle itself; the bundle carries
|
|
9
|
+
// `kind` plus `schemaVersion` instead. Lifted verbatim from dsg-kernel
|
|
10
|
+
// packages/signing/src/law-schema.ts at ffafe305, byte-identical to the
|
|
11
|
+
// module registry copy at 1f8c994.
|
|
12
|
+
import { Type, type Static } from "@sinclair/typebox";
|
|
13
|
+
import type { ProfileEntry } from "../primitives.js";
|
|
14
|
+
import { RESOURCE_DESCRIPTOR_PROFILE } from "./resource-descriptor.v1.js";
|
|
15
|
+
|
|
16
|
+
export const SIGNED_LAW_PROFILE = "dsg.infra.signed-law/1" as const;
|
|
17
|
+
/** The signature-input domain member is exactly the profile literal. */
|
|
18
|
+
export const SIGNED_LAW_DOMAIN = SIGNED_LAW_PROFILE;
|
|
19
|
+
|
|
20
|
+
/** The scope vocabulary version today's laws cite in
|
|
21
|
+
* standingOrder.scopeReference. The FIELD stays an open nonempty string on
|
|
22
|
+
* purpose (a law may cite a future scope); this constant is the value in
|
|
23
|
+
* force, exported so no consumer hand-types it. */
|
|
24
|
+
export const SCOPE_REFERENCE = "dsg.infra.scope/1" as const;
|
|
25
|
+
|
|
26
|
+
/** The price-profile version today's laws cite in priceProfile.reference.
|
|
27
|
+
* Same rule: the field stays open; this is the value in force. */
|
|
28
|
+
export const PRICE_PROFILE_REFERENCE = "dsg.infra.price-profile/1" as const;
|
|
29
|
+
|
|
30
|
+
const nullableString = Type.Union([Type.String({ minLength: 1 }), Type.Null()]);
|
|
31
|
+
const authority = Type.Object(
|
|
32
|
+
{
|
|
33
|
+
issuerType: Type.Literal("human"),
|
|
34
|
+
issuerReference: nullableString,
|
|
35
|
+
designationReference: nullableString,
|
|
36
|
+
signatureReference: nullableString,
|
|
37
|
+
humanSignatureRequired: Type.Literal(true),
|
|
38
|
+
releaseAutomationMayIssue: Type.Literal(false),
|
|
39
|
+
},
|
|
40
|
+
{ additionalProperties: false },
|
|
41
|
+
);
|
|
42
|
+
const utcSecond = Type.String({
|
|
43
|
+
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
|
|
44
|
+
});
|
|
45
|
+
const standingOrder = Type.Object(
|
|
46
|
+
{
|
|
47
|
+
reference: nullableString,
|
|
48
|
+
designationReference: nullableString,
|
|
49
|
+
scopeReference: Type.String({ minLength: 1 }),
|
|
50
|
+
issuedAt: Type.Union([utcSecond, Type.Null()]),
|
|
51
|
+
expiresAt: Type.Union([utcSecond, Type.Null()]),
|
|
52
|
+
},
|
|
53
|
+
{ additionalProperties: false },
|
|
54
|
+
);
|
|
55
|
+
const scope = Type.Object(
|
|
56
|
+
{
|
|
57
|
+
actions: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, uniqueItems: true }),
|
|
58
|
+
workloadClasses: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, uniqueItems: true }),
|
|
59
|
+
providers: Type.Array(Type.Literal("provider-neutral"), { minItems: 1, uniqueItems: true }),
|
|
60
|
+
regions: Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }),
|
|
61
|
+
resourceDescriptorVersion: Type.Literal(RESOURCE_DESCRIPTOR_PROFILE),
|
|
62
|
+
},
|
|
63
|
+
{ additionalProperties: false },
|
|
64
|
+
);
|
|
65
|
+
const validity = Type.Object(
|
|
66
|
+
{
|
|
67
|
+
clock: Type.Literal("UTC"),
|
|
68
|
+
notBefore: Type.Union([utcSecond, Type.Null()]),
|
|
69
|
+
notAfter: Type.Union([utcSecond, Type.Null()]),
|
|
70
|
+
},
|
|
71
|
+
{ additionalProperties: false },
|
|
72
|
+
);
|
|
73
|
+
const revocation = Type.Object(
|
|
74
|
+
{
|
|
75
|
+
snapshotReference: nullableString,
|
|
76
|
+
failClosed: Type.Literal(true),
|
|
77
|
+
checks: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, uniqueItems: true }),
|
|
78
|
+
},
|
|
79
|
+
{ additionalProperties: false },
|
|
80
|
+
);
|
|
81
|
+
const ceiling = Type.Object(
|
|
82
|
+
{
|
|
83
|
+
unit: Type.String({ minLength: 1 }),
|
|
84
|
+
period: Type.String({ minLength: 1 }),
|
|
85
|
+
scope: Type.Union([Type.Literal("person"), Type.Literal("organization")]),
|
|
86
|
+
value: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
|
|
87
|
+
},
|
|
88
|
+
{ additionalProperties: false },
|
|
89
|
+
);
|
|
90
|
+
const capabilityProfile = Type.Object(
|
|
91
|
+
{
|
|
92
|
+
lifecycle: Type.Union([Type.Literal("ephemeral"), Type.Literal("durable")]),
|
|
93
|
+
machinePrefixes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, uniqueItems: true }),
|
|
94
|
+
accelerators: Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }),
|
|
95
|
+
maxRunSeconds: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
|
|
96
|
+
maxParallelism: Type.Union([Type.Integer({ minimum: 1 }), Type.Null()]),
|
|
97
|
+
maxGpuInstances: Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]),
|
|
98
|
+
maxVcpus: Type.Union([Type.Integer({ minimum: 1 }), Type.Null()]),
|
|
99
|
+
network: Type.Literal("private"),
|
|
100
|
+
externalIpAllowed: Type.Literal(false),
|
|
101
|
+
},
|
|
102
|
+
{ additionalProperties: false },
|
|
103
|
+
);
|
|
104
|
+
const capabilities = Type.Object(
|
|
105
|
+
{
|
|
106
|
+
providerNeutral: Type.Literal(true),
|
|
107
|
+
descriptorVersion: Type.Literal(RESOURCE_DESCRIPTOR_PROFILE),
|
|
108
|
+
profiles: Type.Record(Type.String(), capabilityProfile, { minProperties: 1 }),
|
|
109
|
+
},
|
|
110
|
+
{ additionalProperties: false },
|
|
111
|
+
);
|
|
112
|
+
const priceProfile = Type.Object(
|
|
113
|
+
{
|
|
114
|
+
reference: Type.String({ minLength: 1 }),
|
|
115
|
+
status: Type.Union([Type.Literal("unassigned"), Type.Literal("retained")]),
|
|
116
|
+
currency: Type.Literal("USD"),
|
|
117
|
+
unit: Type.Literal("micro_usd"),
|
|
118
|
+
basis: Type.Literal("retained-conservative-on-demand"),
|
|
119
|
+
rates: Type.Object(
|
|
120
|
+
{
|
|
121
|
+
vcpuSecond: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
122
|
+
memoryGiBSecond: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
123
|
+
gpuSecond: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
124
|
+
startup: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
125
|
+
},
|
|
126
|
+
{ additionalProperties: false },
|
|
127
|
+
),
|
|
128
|
+
safetyFactorBps: Type.Union([Type.Integer({ minimum: 10000 }), Type.Null()]),
|
|
129
|
+
validFrom: Type.Union([utcSecond, Type.Null()]),
|
|
130
|
+
validUntil: Type.Union([utcSecond, Type.Null()]),
|
|
131
|
+
},
|
|
132
|
+
{ additionalProperties: false },
|
|
133
|
+
);
|
|
134
|
+
const bootstrap = Type.Object(
|
|
135
|
+
{
|
|
136
|
+
mode: Type.Literal("finite-human-root"),
|
|
137
|
+
rootReferences: Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }),
|
|
138
|
+
allowedActions: Type.Array(
|
|
139
|
+
Type.Union([
|
|
140
|
+
Type.Literal("enroll_human_root"),
|
|
141
|
+
Type.Literal("initialize_kernel_record"),
|
|
142
|
+
Type.Literal("restore_kernel_record"),
|
|
143
|
+
Type.Literal("cutover_single_writer"),
|
|
144
|
+
]),
|
|
145
|
+
{ minItems: 1, uniqueItems: true },
|
|
146
|
+
),
|
|
147
|
+
maxUses: Type.Integer({ minimum: 1, maximum: 1 }),
|
|
148
|
+
expiresAt: Type.Union([utcSecond, Type.Null()]),
|
|
149
|
+
projectCreationAllowed: Type.Literal(false),
|
|
150
|
+
requiresHumanSignature: Type.Literal(true),
|
|
151
|
+
automationCanSatisfy: Type.Literal(false),
|
|
152
|
+
},
|
|
153
|
+
{ additionalProperties: false },
|
|
154
|
+
);
|
|
155
|
+
const digest = Type.String({ pattern: "^sha256:[0-9a-f]{64}$" });
|
|
156
|
+
const policyBundle = Type.Object(
|
|
157
|
+
{
|
|
158
|
+
digest: digest,
|
|
159
|
+
manifest: Type.Record(
|
|
160
|
+
Type.String({ pattern: "^policy/[A-Za-z0-9._-]+\\.rego$" }),
|
|
161
|
+
Type.String({ pattern: "^[0-9a-f]{64}$" }),
|
|
162
|
+
{ additionalProperties: false, minProperties: 1 },
|
|
163
|
+
),
|
|
164
|
+
},
|
|
165
|
+
{ additionalProperties: false },
|
|
166
|
+
);
|
|
167
|
+
const lawInputProfile = Type.Object(
|
|
168
|
+
{
|
|
169
|
+
requiresRunCeiling: Type.Boolean(),
|
|
170
|
+
requiresExpirationLabel: Type.Boolean(),
|
|
171
|
+
maxRunSeconds: Type.Integer({ minimum: 1 }),
|
|
172
|
+
allowExternalIp: Type.Literal(false),
|
|
173
|
+
machinePrefixes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, uniqueItems: true }),
|
|
174
|
+
accelerators: Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }),
|
|
175
|
+
maxGpuInstances: Type.Integer({ minimum: 0 }),
|
|
176
|
+
maxTotalVcpus: Type.Integer({ minimum: 1 }),
|
|
177
|
+
maxParallelism: Type.Integer({ minimum: 1 }),
|
|
178
|
+
network: Type.Literal("private"),
|
|
179
|
+
},
|
|
180
|
+
{ additionalProperties: false },
|
|
181
|
+
);
|
|
182
|
+
const lawInputs = Type.Object(
|
|
183
|
+
{
|
|
184
|
+
cloudflare: Type.Object(
|
|
185
|
+
{
|
|
186
|
+
approvedZoneId: Type.String({ minLength: 1 }),
|
|
187
|
+
approvedAccountId: Type.String({ minLength: 1 }),
|
|
188
|
+
},
|
|
189
|
+
{ additionalProperties: false },
|
|
190
|
+
),
|
|
191
|
+
planLimits: Type.Object(
|
|
192
|
+
{
|
|
193
|
+
maxGpuInstances: Type.Integer({ minimum: 0 }),
|
|
194
|
+
maxTotalVcpus: Type.Integer({ minimum: 1 }),
|
|
195
|
+
approvedLocations: Type.Array(Type.String({ minLength: 1 }), {
|
|
196
|
+
minItems: 1,
|
|
197
|
+
uniqueItems: true,
|
|
198
|
+
}),
|
|
199
|
+
},
|
|
200
|
+
{ additionalProperties: false },
|
|
201
|
+
),
|
|
202
|
+
profiles: Type.Object(
|
|
203
|
+
{ compute: lawInputProfile, plane: lawInputProfile },
|
|
204
|
+
{ additionalProperties: false },
|
|
205
|
+
),
|
|
206
|
+
},
|
|
207
|
+
{ additionalProperties: false },
|
|
208
|
+
);
|
|
209
|
+
const evaluationInputs = Type.Object(
|
|
210
|
+
{ policyBundle: policyBundle, lawInputs: lawInputs },
|
|
211
|
+
{ additionalProperties: false },
|
|
212
|
+
);
|
|
213
|
+
const lawDocument = Type.Object(
|
|
214
|
+
{
|
|
215
|
+
schemaVersion: Type.Literal(1),
|
|
216
|
+
kind: Type.Literal("dsg.infra.law"),
|
|
217
|
+
lawId: Type.String({ minLength: 1 }),
|
|
218
|
+
status: Type.Union([Type.Literal("unissued"), Type.Literal("issued")]),
|
|
219
|
+
authority: authority,
|
|
220
|
+
standingOrder: standingOrder,
|
|
221
|
+
scope: scope,
|
|
222
|
+
validity: validity,
|
|
223
|
+
revocation: revocation,
|
|
224
|
+
ceilings: Type.Object(
|
|
225
|
+
{
|
|
226
|
+
gpuSecondsPerPersonUtcWeek: ceiling,
|
|
227
|
+
usdMicroUnitsPerPersonUtcMonth: ceiling,
|
|
228
|
+
usdMicroUnitsPerOrganizationUtcMonth: ceiling,
|
|
229
|
+
},
|
|
230
|
+
{ additionalProperties: false },
|
|
231
|
+
),
|
|
232
|
+
capabilities: capabilities,
|
|
233
|
+
priceProfile: priceProfile,
|
|
234
|
+
bootstrap: bootstrap,
|
|
235
|
+
evaluationInputs: evaluationInputs,
|
|
236
|
+
},
|
|
237
|
+
{ additionalProperties: false },
|
|
238
|
+
);
|
|
239
|
+
const signature = Type.Object(
|
|
240
|
+
{
|
|
241
|
+
algorithm: Type.Literal("Ed25519"),
|
|
242
|
+
keyClass: Type.Union([
|
|
243
|
+
Type.Literal("synthetic-test-only"),
|
|
244
|
+
Type.Literal("human-authority"),
|
|
245
|
+
Type.Literal("release-automation"),
|
|
246
|
+
]),
|
|
247
|
+
publicKeyHex: Type.String({ pattern: "^[0-9a-f]{64}$" }),
|
|
248
|
+
signatureHex: Type.String({ pattern: "^[0-9a-f]{128}$" }),
|
|
249
|
+
},
|
|
250
|
+
{ additionalProperties: false },
|
|
251
|
+
);
|
|
252
|
+
const signedLawBundle = Type.Object(
|
|
253
|
+
{
|
|
254
|
+
schemaVersion: Type.Literal(1),
|
|
255
|
+
kind: Type.Union([
|
|
256
|
+
Type.Literal("dsg.infra.signed-law"),
|
|
257
|
+
Type.Literal("dsg.infra.signed-law-fixture"),
|
|
258
|
+
]),
|
|
259
|
+
testOnly: Type.Boolean(),
|
|
260
|
+
deployedAuthority: Type.Boolean(),
|
|
261
|
+
payload: lawDocument,
|
|
262
|
+
canonicalPayload: Type.String({ minLength: 1 }),
|
|
263
|
+
payloadSha256: Type.String({ pattern: "^[0-9a-f]{64}$" }),
|
|
264
|
+
canonicalSignatureInput: Type.String({ minLength: 1 }),
|
|
265
|
+
signature: signature,
|
|
266
|
+
},
|
|
267
|
+
{ additionalProperties: false },
|
|
268
|
+
);
|
|
269
|
+
export const SignedLawBundleSchema = signedLawBundle;
|
|
270
|
+
export type SignedLawBundle = Static<typeof SignedLawBundleSchema>;
|
|
271
|
+
|
|
272
|
+
export const signedLawV1: ProfileEntry = {
|
|
273
|
+
literal: SIGNED_LAW_PROFILE,
|
|
274
|
+
literalNote:
|
|
275
|
+
"carried as the domain member of the canonical signature input, not as a bundle field",
|
|
276
|
+
shapes: { bundle: SignedLawBundleSchema },
|
|
277
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// dsg.kernel.bootstrap/1
|
|
2
|
+
// Owner: dsg-kernel (K14). The finite bootstrap intent: a signed,
|
|
3
|
+
// single-use, expiring authorization for exactly one of four record
|
|
4
|
+
// actions, binding plan and resource-spec digests. enroll_human_root
|
|
5
|
+
// (M030) is the additive action that anchors ordinary-authority
|
|
6
|
+
// enrollment; initialization is never reinterpreted as enrollment. The
|
|
7
|
+
// record-held bootstrap event payloads stay in the kernel.
|
|
8
|
+
//
|
|
9
|
+
// Lifted verbatim from dsg-kernel packages/core/src/contracts.ts at
|
|
10
|
+
// 00b33ac1. createdAt/expiresAt are frozen /1 nonempty strings, recorded
|
|
11
|
+
// in FROZEN_EXEMPTIONS; exact-second patterns would be a /2 against
|
|
12
|
+
// already-recorded signed intents.
|
|
13
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
14
|
+
import { closed, Hex64, NonEmptyString, Orn, type ProfileEntry } from "../primitives.js";
|
|
15
|
+
|
|
16
|
+
export const BOOTSTRAP_PROFILE = "dsg.kernel.bootstrap/1" as const;
|
|
17
|
+
|
|
18
|
+
const BootstrapActionSchemaValue = Type.Union([
|
|
19
|
+
Type.Literal("initialize_kernel_record"),
|
|
20
|
+
Type.Literal("restore_kernel_record"),
|
|
21
|
+
Type.Literal("cutover_single_writer"),
|
|
22
|
+
Type.Literal("enroll_human_root"),
|
|
23
|
+
]);
|
|
24
|
+
export const BootstrapActionSchema: typeof BootstrapActionSchemaValue = BootstrapActionSchemaValue;
|
|
25
|
+
export type BootstrapAction = Static<typeof BootstrapActionSchema>;
|
|
26
|
+
|
|
27
|
+
const BootstrapIntentSchemaValue = closed({
|
|
28
|
+
version: Type.Literal(BOOTSTRAP_PROFILE),
|
|
29
|
+
operation: NonEmptyString,
|
|
30
|
+
action: BootstrapActionSchema,
|
|
31
|
+
lineage: NonEmptyString,
|
|
32
|
+
humanRoot: NonEmptyString,
|
|
33
|
+
signer: Orn,
|
|
34
|
+
scope: NonEmptyString,
|
|
35
|
+
resources: Type.Array(
|
|
36
|
+
closed({
|
|
37
|
+
identity: NonEmptyString,
|
|
38
|
+
specSha256: Hex64,
|
|
39
|
+
}),
|
|
40
|
+
{ minItems: 1, uniqueItems: true },
|
|
41
|
+
),
|
|
42
|
+
planSha256: Hex64,
|
|
43
|
+
preconditionsSha256: Hex64,
|
|
44
|
+
createdAt: NonEmptyString,
|
|
45
|
+
expiresAt: NonEmptyString,
|
|
46
|
+
maxUses: Type.Literal(1),
|
|
47
|
+
cost: closed({
|
|
48
|
+
currency: Type.Literal("USD"),
|
|
49
|
+
maxMicroUsd: Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }),
|
|
50
|
+
assumptionsSha256: Hex64,
|
|
51
|
+
}),
|
|
52
|
+
testOnly: Type.Boolean(),
|
|
53
|
+
});
|
|
54
|
+
export const BootstrapIntentSchema: typeof BootstrapIntentSchemaValue = BootstrapIntentSchemaValue;
|
|
55
|
+
export type BootstrapIntent = Static<typeof BootstrapIntentSchema>;
|
|
56
|
+
|
|
57
|
+
const SignedBootstrapIntentSchemaValue = closed({
|
|
58
|
+
body: BootstrapIntentSchema,
|
|
59
|
+
signature: Type.String({ pattern: "^[0-9a-f]{128}$" }),
|
|
60
|
+
});
|
|
61
|
+
export const SignedBootstrapIntentSchema: typeof SignedBootstrapIntentSchemaValue =
|
|
62
|
+
SignedBootstrapIntentSchemaValue;
|
|
63
|
+
export type SignedBootstrapIntent = Static<typeof SignedBootstrapIntentSchema>;
|
|
64
|
+
|
|
65
|
+
export const bootstrapV1: ProfileEntry = {
|
|
66
|
+
literal: BOOTSTRAP_PROFILE,
|
|
67
|
+
shapes: { intent: BootstrapIntentSchema, signed: SignedBootstrapIntentSchema },
|
|
68
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// dsg.kernel.dispatch-consume/1
|
|
2
|
+
// Owner: dsg-kernel (the consume route produces the lease and the refusal;
|
|
3
|
+
// the plane produces the request).
|
|
4
|
+
//
|
|
5
|
+
// K05/I3: the dispatch-authorization consume contract between the kernel
|
|
6
|
+
// and the plane. Immediately before its first non-cleanup cloud mutation -
|
|
7
|
+
// identity, bucket and IAM preparation included, not only job submission -
|
|
8
|
+
// the plane consumes a short-lived, single-operation dispatch authorization
|
|
9
|
+
// bound to operation, generation, envelope digest, law digest and
|
|
10
|
+
// reservation. The committed consume event is the authorization ordering
|
|
11
|
+
// point; it is not atomic with any provider API. A replay returns the
|
|
12
|
+
// original lease and never renews it; a renewal is a new recorded
|
|
13
|
+
// authorization decision for the same operation and reservation.
|
|
14
|
+
//
|
|
15
|
+
// Lifted verbatim from dsg-kernel packages/core/src/dispatch.ts at commit
|
|
16
|
+
// c2d39d95 (wire shapes only; the record-held event payloads stay in the
|
|
17
|
+
// kernel). This file is frozen: changes ship as dispatch-consume.v2.ts.
|
|
18
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
19
|
+
import {
|
|
20
|
+
closed,
|
|
21
|
+
Hex64,
|
|
22
|
+
NonEmptyString,
|
|
23
|
+
Orn,
|
|
24
|
+
Reference,
|
|
25
|
+
UtcSecond,
|
|
26
|
+
type ProfileEntry,
|
|
27
|
+
} from "../primitives.js";
|
|
28
|
+
|
|
29
|
+
export const DISPATCH_CONSUME_PROFILE = "dsg.kernel.dispatch-consume/1" as const;
|
|
30
|
+
|
|
31
|
+
/** The bounded clock skew a lease check must tolerate, in seconds. */
|
|
32
|
+
export const DISPATCH_MAX_SKEW_SECONDS = 300;
|
|
33
|
+
|
|
34
|
+
const DispatchConsumeRequestSchemaValue = closed({
|
|
35
|
+
profile: Type.Literal(DISPATCH_CONSUME_PROFILE),
|
|
36
|
+
/** The kernel operation identity from the accepted OperationRequest. */
|
|
37
|
+
operationId: NonEmptyString,
|
|
38
|
+
/** The workspace generation the plane admitted the operation at. */
|
|
39
|
+
generation: Type.Integer({ minimum: 0 }),
|
|
40
|
+
/** The Case the operation belongs to - the stream the consume event
|
|
41
|
+
* lands on and the stream the reservation was recorded on. */
|
|
42
|
+
caseOrn: Orn,
|
|
43
|
+
/** SHA256(JCS(complete OperationRequest)) - the M010 envelope digest. */
|
|
44
|
+
envelopeSha256: Hex64,
|
|
45
|
+
/** The exact retained signed-law bytes the Case pins. */
|
|
46
|
+
lawSha256: Hex64,
|
|
47
|
+
/** The K04 reservation the authorization is bound to: sha256 is the
|
|
48
|
+
* reservation event's record id. */
|
|
49
|
+
reservation: Reference,
|
|
50
|
+
requestedAt: UtcSecond,
|
|
51
|
+
/** False: first consumption or idempotent replay of it. True: an explicit
|
|
52
|
+
* renewal - a new recorded authorization decision for the same operation
|
|
53
|
+
* and reservation after lease expiry with the work known unsubmitted. A
|
|
54
|
+
* replay never renews; only this flag does, and it re-runs every
|
|
55
|
+
* revocation check at the current record state. */
|
|
56
|
+
renewal: Type.Boolean(),
|
|
57
|
+
});
|
|
58
|
+
export const DispatchConsumeRequestSchema: typeof DispatchConsumeRequestSchemaValue =
|
|
59
|
+
DispatchConsumeRequestSchemaValue;
|
|
60
|
+
export type DispatchConsumeRequest = Static<typeof DispatchConsumeRequestSchema>;
|
|
61
|
+
|
|
62
|
+
const DispatchLeaseSchemaValue = closed({
|
|
63
|
+
profile: Type.Literal(DISPATCH_CONSUME_PROFILE),
|
|
64
|
+
/** The consume event's record id: the committed ordering point. */
|
|
65
|
+
leaseId: Hex64,
|
|
66
|
+
operationId: NonEmptyString,
|
|
67
|
+
generation: Type.Integer({ minimum: 0 }),
|
|
68
|
+
caseOrn: Orn,
|
|
69
|
+
envelopeSha256: Hex64,
|
|
70
|
+
lawSha256: Hex64,
|
|
71
|
+
reservation: Reference,
|
|
72
|
+
consumedAt: UtcSecond,
|
|
73
|
+
/** Fixed maximum duration from consumedAt; the plane checks validity
|
|
74
|
+
* before each new non-cleanup call, Batch submission included. */
|
|
75
|
+
expiresAt: UtcSecond,
|
|
76
|
+
/** The bounded clock skew a lease check must tolerate, in seconds. */
|
|
77
|
+
maxSkewSeconds: Type.Integer({ minimum: 0, maximum: DISPATCH_MAX_SKEW_SECONDS }),
|
|
78
|
+
renewal: Type.Literal("new-authorization-required"),
|
|
79
|
+
/** False when this response replays an earlier committed consumption:
|
|
80
|
+
* the lease bytes, expiry included, are the original's. */
|
|
81
|
+
fresh: Type.Boolean(),
|
|
82
|
+
});
|
|
83
|
+
export const DispatchLeaseSchema: typeof DispatchLeaseSchemaValue = DispatchLeaseSchemaValue;
|
|
84
|
+
export type DispatchLease = Static<typeof DispatchLeaseSchema>;
|
|
85
|
+
|
|
86
|
+
const DispatchRefusalCodeSchemaValue = Type.Union([
|
|
87
|
+
Type.Literal("unknown_operation"),
|
|
88
|
+
Type.Literal("no_reservation"),
|
|
89
|
+
Type.Literal("binding_mismatch"),
|
|
90
|
+
Type.Literal("revoked"),
|
|
91
|
+
Type.Literal("authority_refused"),
|
|
92
|
+
Type.Literal("renewal_requires_existing_consumption"),
|
|
93
|
+
Type.Literal("unavailable"),
|
|
94
|
+
]);
|
|
95
|
+
export const DispatchRefusalCodeSchema: typeof DispatchRefusalCodeSchemaValue =
|
|
96
|
+
DispatchRefusalCodeSchemaValue;
|
|
97
|
+
export type DispatchRefusalCode = Static<typeof DispatchRefusalCodeSchema>;
|
|
98
|
+
|
|
99
|
+
const DispatchRefusalSchemaValue = closed({
|
|
100
|
+
profile: Type.Literal(DISPATCH_CONSUME_PROFILE),
|
|
101
|
+
code: DispatchRefusalCodeSchema,
|
|
102
|
+
issues: Type.Array(NonEmptyString, { minItems: 1 }),
|
|
103
|
+
});
|
|
104
|
+
export const DispatchRefusalSchema: typeof DispatchRefusalSchemaValue = DispatchRefusalSchemaValue;
|
|
105
|
+
export type DispatchRefusal = Static<typeof DispatchRefusalSchema>;
|
|
106
|
+
|
|
107
|
+
export const dispatchConsumeV1: ProfileEntry = {
|
|
108
|
+
literal: DISPATCH_CONSUME_PROFILE,
|
|
109
|
+
shapes: {
|
|
110
|
+
request: DispatchConsumeRequestSchema,
|
|
111
|
+
lease: DispatchLeaseSchema,
|
|
112
|
+
refusal: DispatchRefusalSchema,
|
|
113
|
+
},
|
|
114
|
+
};
|