@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.
@@ -0,0 +1,53 @@
1
+ // dsg.kernel.ordinary-authority/1
2
+ // Owner: dsg-kernel (K02, M029/M030). The canonical ordinary-rights
3
+ // artifact: who may issue law, exactly what they may permit, for how long,
4
+ // and under which three ceilings. Closed and versioned; every set is an
5
+ // explicit allow-list, never an omitted-means-unlimited default. A
6
+ // verified finite enroll_human_root intent binds this document's digest as
7
+ // both plan and resource spec. The revocation view a standing-order check
8
+ // runs against stays in the kernel: independently supplied input, not a
9
+ // wire document.
10
+ //
11
+ // Lifted verbatim from dsg-kernel packages/signing/src/enrollment.ts at
12
+ // 00b33ac1.
13
+ import { type Static, Type } from "@sinclair/typebox";
14
+ import { closed, Hex64, NonEmptyString, Orn, UtcSecond, type ProfileEntry } from "../primitives.js";
15
+
16
+ export const ORDINARY_AUTHORITY_PROFILE = "dsg.kernel.ordinary-authority/1" as const;
17
+
18
+ const names = Type.Array(NonEmptyString, { minItems: 1, uniqueItems: true });
19
+ const ceilingValue = Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
20
+
21
+ const OrdinaryAuthoritySchemaValue = closed({
22
+ version: Type.Literal(ORDINARY_AUTHORITY_PROFILE),
23
+ reference: NonEmptyString,
24
+ actor: Orn,
25
+ publicKeyHex: Hex64,
26
+ keyClass: Type.Union([Type.Literal("synthetic-test-only"), Type.Literal("human-authority")]),
27
+ designation: closed({
28
+ role: Type.Literal("law-issuer"),
29
+ designationReference: NonEmptyString,
30
+ }),
31
+ scope: closed({
32
+ scopeReference: NonEmptyString,
33
+ actions: names,
34
+ workloadClasses: names,
35
+ regions: names,
36
+ }),
37
+ validity: closed({ notBefore: UtcSecond, notAfter: UtcSecond }),
38
+ ceilings: closed({
39
+ gpuSecondsPerPersonUtcWeek: ceilingValue,
40
+ usdMicroUnitsPerPersonUtcMonth: ceilingValue,
41
+ usdMicroUnitsPerOrganizationUtcMonth: ceilingValue,
42
+ }),
43
+ revoked: Type.Boolean(),
44
+ });
45
+ export const OrdinaryAuthoritySchema: typeof OrdinaryAuthoritySchemaValue =
46
+ OrdinaryAuthoritySchemaValue;
47
+ export type OrdinaryAuthority = Static<typeof OrdinaryAuthoritySchema>;
48
+
49
+ export const ordinaryAuthorityV1: ProfileEntry = {
50
+ literal: ORDINARY_AUTHORITY_PROFILE,
51
+ rootShape: "authority",
52
+ shapes: { authority: OrdinaryAuthoritySchema },
53
+ };
@@ -0,0 +1,49 @@
1
+ // The shared primitives every profile builds from. No profile defines its
2
+ // own: a digest is Hex64 everywhere, a timestamp is UtcSecond everywhere,
3
+ // an open object exists nowhere.
4
+ import { type TObject, type TProperties, type TSchema, Type } from "@sinclair/typebox";
5
+ import { ORN_PATTERN, SHA256_PATTERN } from "@dynamicalsystems/orn-schemas";
6
+
7
+ /** Closed object: an extra field is a different protocol. */
8
+ export const closed = <T extends TProperties>(properties: T): TObject<T> =>
9
+ Type.Object(properties, { additionalProperties: false });
10
+
11
+ /** Lowercase sha256 hex. Every digest on the wire. */
12
+ export const Hex64 = Type.String({ pattern: "^[0-9a-f]{64}$" });
13
+
14
+ /** Exact UTC second, Z suffix, no fractional part. */
15
+ export const UtcSecond = Type.String({
16
+ pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
17
+ });
18
+
19
+ export const NonEmptyString = Type.String({ minLength: 1 });
20
+
21
+ export const SafeInt = Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
22
+
23
+ /** An ORN, validated by the grammar dsg-orn owns. Built from the exported
24
+ * pattern, not the exported schema object: the upstream schemas carry
25
+ * JSON Schema $id metadata, and embedding the same $id in several route
26
+ * schemas makes validators refuse the duplicate. The pattern is the wire
27
+ * truth; the metadata is not. */
28
+ export const Orn = Type.String({ pattern: ORN_PATTERN });
29
+
30
+ /** The pair of an ORN and the sha256 pinning a version (dsg-orn Reference). */
31
+ export const Reference = closed({
32
+ orn: Orn,
33
+ sha256: Type.String({ pattern: SHA256_PATTERN }),
34
+ });
35
+
36
+ /** One wire profile: the literal, and every top-level shape that crosses
37
+ * the seam it names. Shape names are stable identifiers ("request",
38
+ * "lease", "refusal"); vectors address a shape as "<literal>#<shape>". */
39
+ export type ProfileEntry = {
40
+ readonly literal: `dsg.${string}.${string}/${number}`;
41
+ readonly shapes: Readonly<Record<string, TSchema>>;
42
+ /** Set ONLY when the wire cannot carry the literal as a field of any
43
+ * shape (a frozen /1); names exactly where the literal lives instead. */
44
+ readonly literalNote?: string;
45
+ /** Names the shape non-TS consumers validate a whole document against;
46
+ * the emitted JSON Schema gains a root $ref to it. Only meaningful for
47
+ * profiles with a single document root. */
48
+ readonly rootShape?: string;
49
+ };
@@ -0,0 +1,87 @@
1
+ // dsg.registry.revocations/1
2
+ // Owner: dsg-infra-module-registry (the S03 trust producer). Signed,
3
+ // monotonically versioned revocation snapshots with retained trust
4
+ // history; timestamps are epoch seconds by frozen choice of /1 (recorded
5
+ // in FROZEN_EXEMPTIONS; exact-second strings would be a /2).
6
+ // Lifted verbatim from dsg-infra-module-registry src/revocation.ts at
7
+ // 1f8c994.
8
+ import { Type, type Static } from "@sinclair/typebox";
9
+ import type { ProfileEntry } from "../primitives.js";
10
+
11
+ export const REVOCATIONS_PROFILE = "dsg.registry.revocations/1" as const;
12
+
13
+ const closed = { additionalProperties: false };
14
+ const text = Type.String({ minLength: 1 });
15
+ const digest = Type.String({ pattern: "^[0-9a-f]{64}$" });
16
+ const time = Type.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
17
+
18
+ const RevocationSchemaValue = Type.Object(
19
+ {
20
+ domain: Type.Literal(REVOCATIONS_PROFILE),
21
+ version: Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
22
+ issuedAt: time,
23
+ expiresAt: time,
24
+ previousSha256: Type.Union([digest, Type.Null()]),
25
+ testOnly: Type.Literal(true),
26
+ signerKey: digest,
27
+ revoked: Type.Array(
28
+ Type.Object(
29
+ {
30
+ kind: Type.Union([
31
+ Type.Literal("principal"),
32
+ Type.Literal("standing-order"),
33
+ Type.Literal("law"),
34
+ Type.Literal("class"),
35
+ Type.Literal("key"),
36
+ ]),
37
+ id: text,
38
+ effectiveAt: time,
39
+ reason: text,
40
+ },
41
+ closed,
42
+ ),
43
+ ),
44
+ trustHistory: Type.Array(
45
+ Type.Object(
46
+ {
47
+ principal: text,
48
+ publicKey: digest,
49
+ role: Type.Union([
50
+ Type.Literal("human"),
51
+ Type.Literal("release"),
52
+ Type.Literal("collector"),
53
+ ]),
54
+ action: Type.Union([
55
+ Type.Literal("enroll"),
56
+ Type.Literal("rotate"),
57
+ Type.Literal("compromise"),
58
+ ]),
59
+ effectiveAt: time,
60
+ authoritySha256: digest,
61
+ replacesKey: Type.Union([digest, Type.Null()]),
62
+ },
63
+ closed,
64
+ ),
65
+ ),
66
+ },
67
+ closed,
68
+ );
69
+ export const RevocationSchema: typeof RevocationSchemaValue = RevocationSchemaValue;
70
+ export type RevocationSnapshot = Static<typeof RevocationSchema>;
71
+
72
+ const RevocationPointerSchemaValue = Type.Object(
73
+ {
74
+ version: Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
75
+ sha256: digest,
76
+ url: Type.String({ pattern: "^/revocations/v/[1-9][0-9]*/snapshot\\.json$" }),
77
+ },
78
+ closed,
79
+ );
80
+ export const RevocationPointerSchema: typeof RevocationPointerSchemaValue =
81
+ RevocationPointerSchemaValue;
82
+ export type RevocationPointer = Static<typeof RevocationPointerSchema>;
83
+
84
+ export const revocationsV1: ProfileEntry = {
85
+ literal: REVOCATIONS_PROFILE,
86
+ shapes: { snapshot: RevocationSchema, pointer: RevocationPointerSchema },
87
+ };
@@ -0,0 +1,13 @@
1
+ // In-process contract versions of the dsg-run plane. Under ruling I7 these
2
+ // are NOT profiles: an executor or provider adapter is a TypeScript plugin
3
+ // interface inside one process, with no serialized shape or digest of its
4
+ // own - its documents (operation requests, descriptors) already have
5
+ // profiles. The literals live here so no consumer repo defines a
6
+ // dsg.*.*/N string and the CI grep stays absolute. When R06 gives
7
+ // executors a real serialized job document, THAT becomes a profile module
8
+ // beside this file.
9
+ export const EXECUTOR_PROTOCOL_VERSION = "dsg.run.executor/1" as const;
10
+ export type ExecutorProtocolVersion = typeof EXECUTOR_PROTOCOL_VERSION;
11
+
12
+ export const PROVIDER_PROTOCOL_VERSION = "dsg.run.provider/1" as const;
13
+ export type ProviderProtocolVersion = typeof PROVIDER_PROTOCOL_VERSION;
@@ -0,0 +1,158 @@
1
+ // dsg.run.operation/1
2
+ // Owner: dsg-run (the protocol listener accepts the request and answers
3
+ // the receipt; the kernel validates, records and reads back).
4
+ //
5
+ // Closed, versioned compute-operation vocabulary shared by the kernel and
6
+ // the dsg.run plane. The document is deliberately references-only: payload
7
+ // bytes remain retained artifacts, while this request carries the immutable
8
+ // identity, generation fence, law, reservation and plan digest.
9
+ //
10
+ // The envelope digest bound at dispatch (M010) is sha256 over the RFC 8785
11
+ // canonical form of the complete OperationRequest; the digest vectors in
12
+ // the conformance package pin that meaning.
13
+ //
14
+ // Lifted verbatim from dsg-kernel packages/core/src/operation.ts at commit
15
+ // 0f8d64d7 (equal, field for field, to dsg-run service/src/protocol/
16
+ // schemas.ts 134-246 - the R01 cross-validation held). Known /2 candidate,
17
+ // kept loose here because a released /1 is frozen: acceptedAt is
18
+ // minLength 1, not an exact UTC second, and the plane emits fractional
19
+ // seconds today.
20
+ import { type Static, Type } from "@sinclair/typebox";
21
+ import {
22
+ closed,
23
+ Hex64,
24
+ NonEmptyString,
25
+ Reference,
26
+ SafeInt,
27
+ type ProfileEntry,
28
+ } from "../primitives.js";
29
+
30
+ export const OPERATION_PROFILE = "dsg.run.operation/1" as const;
31
+
32
+ const ExecutionResourcesSchemaValue = closed({
33
+ maxGpuSeconds: SafeInt,
34
+ maxRunSeconds: SafeInt,
35
+ maxParallelism: SafeInt,
36
+ });
37
+ export const ExecutionResourcesSchema: typeof ExecutionResourcesSchemaValue =
38
+ ExecutionResourcesSchemaValue;
39
+ export type ExecutionResources = Static<typeof ExecutionResourcesSchema>;
40
+
41
+ const ExecutionLawSchemaValue = closed({
42
+ bundle: Reference,
43
+ registryRelease: Reference,
44
+ });
45
+ export const ExecutionLawSchema: typeof ExecutionLawSchemaValue = ExecutionLawSchemaValue;
46
+ export type ExecutionLaw = Static<typeof ExecutionLawSchema>;
47
+
48
+ const ExecutionDocumentSchemaValue = closed({
49
+ schemaVersion: Type.Literal(1),
50
+ classContract: Reference,
51
+ law: ExecutionLawSchema,
52
+ workload: Reference,
53
+ inputs: Type.Array(Reference),
54
+ resources: ExecutionResourcesSchema,
55
+ costBound: Reference,
56
+ placement: Reference,
57
+ results: Reference,
58
+ secrets: Type.Array(Reference),
59
+ });
60
+ export const ExecutionDocumentSchema: typeof ExecutionDocumentSchemaValue =
61
+ ExecutionDocumentSchemaValue;
62
+ export type ExecutionDocument = Static<typeof ExecutionDocumentSchema>;
63
+
64
+ const OperationBeforeSchemaValue = closed({
65
+ operationId: Type.Union([NonEmptyString, Type.Null()]),
66
+ planDigest: Type.Union([Hex64, Type.Null()]),
67
+ });
68
+ export const OperationBeforeSchema: typeof OperationBeforeSchemaValue = OperationBeforeSchemaValue;
69
+ export type OperationBefore = Static<typeof OperationBeforeSchema>;
70
+
71
+ const OperationRequestSchemaValue = closed({
72
+ profile: Type.Literal(OPERATION_PROFILE),
73
+ operationId: NonEmptyString,
74
+ case: Reference,
75
+ workspace: NonEmptyString,
76
+ expectedGeneration: SafeInt,
77
+ before: OperationBeforeSchema,
78
+ planDigest: Hex64,
79
+ document: ExecutionDocumentSchema,
80
+ authority: Reference,
81
+ reservation: Reference,
82
+ });
83
+ export const OperationRequestSchema: typeof OperationRequestSchemaValue =
84
+ OperationRequestSchemaValue;
85
+ export type OperationRequest = Static<typeof OperationRequestSchema>;
86
+
87
+ const AcceptedSchemaValue = closed({
88
+ profile: Type.Literal(OPERATION_PROFILE),
89
+ operationId: NonEmptyString,
90
+ actionId: NonEmptyString,
91
+ generation: SafeInt,
92
+ planDigest: Hex64,
93
+ acceptedAt: NonEmptyString,
94
+ });
95
+ export const AcceptedSchema: typeof AcceptedSchemaValue = AcceptedSchemaValue;
96
+ export type Accepted = Static<typeof AcceptedSchema>;
97
+
98
+ const OperationExecutionSchemaValue = Type.Union([
99
+ Type.Literal("queued"),
100
+ Type.Literal("running"),
101
+ Type.Literal("succeeded"),
102
+ Type.Literal("failed"),
103
+ Type.Literal("canceled"),
104
+ Type.Literal("unknown"),
105
+ ]);
106
+ export const OperationExecutionSchema: typeof OperationExecutionSchemaValue =
107
+ OperationExecutionSchemaValue;
108
+ export type OperationExecution = Static<typeof OperationExecutionSchema>;
109
+
110
+ const OperationCleanupSchemaValue = Type.Union([
111
+ Type.Literal("pending"),
112
+ Type.Literal("present"),
113
+ Type.Literal("absent"),
114
+ Type.Literal("unknown"),
115
+ ]);
116
+ export const OperationCleanupSchema: typeof OperationCleanupSchemaValue =
117
+ OperationCleanupSchemaValue;
118
+ export type OperationCleanup = Static<typeof OperationCleanupSchema>;
119
+
120
+ const OperationEvidenceSchemaValue = Type.Union([Type.Literal("pending"), Type.Literal("ready")]);
121
+ export const OperationEvidenceSchema: typeof OperationEvidenceSchemaValue =
122
+ OperationEvidenceSchemaValue;
123
+ export type OperationEvidence = Static<typeof OperationEvidenceSchema>;
124
+
125
+ const OperationCostSchemaValue = Type.Union([
126
+ Type.Literal("reserved"),
127
+ Type.Literal("provisional"),
128
+ Type.Literal("reconciled"),
129
+ ]);
130
+ export const OperationCostSchema: typeof OperationCostSchemaValue = OperationCostSchemaValue;
131
+ export type OperationCost = Static<typeof OperationCostSchema>;
132
+
133
+ const ReadbackSchemaValue = closed({
134
+ operationId: NonEmptyString,
135
+ generation: SafeInt,
136
+ planDigest: Hex64,
137
+ execution: OperationExecutionSchema,
138
+ cleanup: OperationCleanupSchema,
139
+ evidence: OperationEvidenceSchema,
140
+ evidenceRef: Type.Union([Reference, Type.Null()]),
141
+ cost: OperationCostSchema,
142
+ });
143
+ export const ReadbackSchema: typeof ReadbackSchemaValue = ReadbackSchemaValue;
144
+ export type Readback = Static<typeof ReadbackSchema>;
145
+
146
+ // I-001 names the status as the same closed readback shape. Keeping this
147
+ // alias prevents callers from inventing a second status wire contract.
148
+ export const OperationStatusSchema = ReadbackSchema;
149
+ export type OperationStatus = Readback;
150
+
151
+ export const operationV1: ProfileEntry = {
152
+ literal: OPERATION_PROFILE,
153
+ shapes: {
154
+ request: OperationRequestSchema,
155
+ accepted: AcceptedSchema,
156
+ readback: ReadbackSchema,
157
+ },
158
+ };