@dynamicalsystems/idl 0.9.0 → 0.11.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.
@@ -0,0 +1,42 @@
1
+ // dsg.core.google-identity/1
2
+ // Owner: dsg-kernel. A verified Google identity, as the kernel sees it:
3
+ // the Google account number is the only identity key and the email
4
+ // address is a display label. The kernel carries googleSubject in the
5
+ // shape "accounts.google.com:<digits>" and never compares email for
6
+ // identity after the claim.
7
+ //
8
+ // This profile ships beside dsg.core.identity-binding/1, which remains
9
+ // the frozen shape of the detached personal-key binding path. The real
10
+ // authority is Google-attested, so a separate profile names what a
11
+ // verified identity looks like on the wire today.
12
+ //
13
+ // googleSubject is required, email is optional. hostedDomain is set
14
+ // when the verified token carries the hd claim; absent is its own
15
+ // meaning, not the same as a missing value. audience is the client id
16
+ // the token was minted for and is required.
17
+ import { type Static, Type } from "@sinclair/typebox";
18
+ import { closed, NonEmptyString, type ProfileEntry } from "../primitives.js";
19
+
20
+ export const GOOGLE_IDENTITY_PROFILE = "dsg.core.google-identity/1" as const;
21
+ export const GOOGLE_SIGN_IN_ISSUER = "https://accounts.google.com" as const;
22
+
23
+ const GoogleAccountSubject = Type.String({
24
+ pattern: "^accounts\\.google\\.com:[0-9]+$",
25
+ });
26
+
27
+ const GoogleIdentitySchemaValue = closed({
28
+ profile: Type.Literal(GOOGLE_IDENTITY_PROFILE),
29
+ issuer: Type.Literal(GOOGLE_SIGN_IN_ISSUER),
30
+ googleSubject: GoogleAccountSubject,
31
+ audience: NonEmptyString,
32
+ hostedDomain: Type.Optional(NonEmptyString),
33
+ email: Type.Optional(NonEmptyString),
34
+ });
35
+ export const GoogleIdentitySchema: typeof GoogleIdentitySchemaValue = GoogleIdentitySchemaValue;
36
+ export type GoogleIdentity = Static<typeof GoogleIdentitySchema>;
37
+
38
+ export const googleIdentityV1: ProfileEntry = {
39
+ literal: GOOGLE_IDENTITY_PROFILE,
40
+ rootDocument: "googleIdentity",
41
+ documents: { googleIdentity: GoogleIdentitySchema },
42
+ };
@@ -21,6 +21,6 @@ export type IdentityBinding = Static<typeof IdentityBindingSchema>;
21
21
 
22
22
  export const identityBindingV1: ProfileEntry = {
23
23
  literal: IDENTITY_BINDING_PROFILE,
24
- rootShape: "binding",
25
- shapes: { binding: IdentityBindingSchema },
24
+ rootDocument: "binding",
25
+ documents: { binding: IdentityBindingSchema },
26
26
  };
@@ -40,6 +40,6 @@ export type Refusal = Static<typeof RefusalSchema>;
40
40
 
41
41
  export const refusalV1: ProfileEntry = {
42
42
  literal: REFUSAL_PROFILE,
43
- rootShape: "refusal",
44
- shapes: { refusal: RefusalSchema },
43
+ rootDocument: "refusal",
44
+ documents: { refusal: RefusalSchema },
45
45
  };
@@ -3,6 +3,14 @@
3
3
  // requires: a validator that cannot answer fails closed and says so, and a
4
4
  // human confirmation outside its window is its own refusal, not a generic
5
5
  // expiry. /1 is frozen; this ships beside it.
6
+ //
7
+ // `stage` and `correlationId` are optional additions (2026-09-11): the
8
+ // system has not shipped, so this profile amends in place rather than
9
+ // spawning a /3 for two backward-compatible optional fields. An existing
10
+ // non-proxy refusal carries neither. A proxy hop (dsg-run-console) always
11
+ // sends both: `stage: "proxy"` names which hop answered, `correlationId`
12
+ // is the proxy's own request id, replacing the `X-DSG-Refusal-Stage` /
13
+ // `X-Request-ID` header detour with in-body fields the same schema covers.
6
14
  import { type Static, Type } from "@sinclair/typebox";
7
15
  import { closed, NonEmptyString, type ProfileEntry } from "../primitives.js";
8
16
 
@@ -32,16 +40,27 @@ const RefusalCodeV2SchemaValue = Type.Union([
32
40
  export const RefusalCodeV2Schema: typeof RefusalCodeV2SchemaValue = RefusalCodeV2SchemaValue;
33
41
  export type RefusalCodeV2 = Static<typeof RefusalCodeV2Schema>;
34
42
 
43
+ const RefusalStageV2SchemaValue = Type.Union([
44
+ Type.Literal("proxy"),
45
+ Type.Literal("provider"),
46
+ Type.Literal("identity_read"),
47
+ Type.Literal("plane"),
48
+ ]);
49
+ export const RefusalStageV2Schema: typeof RefusalStageV2SchemaValue = RefusalStageV2SchemaValue;
50
+ export type RefusalStageV2 = Static<typeof RefusalStageV2Schema>;
51
+
35
52
  const RefusalV2SchemaValue = closed({
36
53
  profile: Type.Literal(REFUSAL_V2_PROFILE),
37
54
  code: RefusalCodeV2Schema,
38
55
  sentence: NonEmptyString,
56
+ stage: Type.Optional(RefusalStageV2Schema),
57
+ correlationId: Type.Optional(NonEmptyString),
39
58
  });
40
59
  export const RefusalV2Schema: typeof RefusalV2SchemaValue = RefusalV2SchemaValue;
41
60
  export type RefusalV2 = Static<typeof RefusalV2Schema>;
42
61
 
43
62
  export const refusalV2: ProfileEntry = {
44
63
  literal: REFUSAL_V2_PROFILE,
45
- rootShape: "refusal",
46
- shapes: { refusal: RefusalV2Schema },
64
+ rootDocument: "refusal",
65
+ documents: { refusal: RefusalV2Schema },
47
66
  };
@@ -0,0 +1,50 @@
1
+ // Normalized organization refusal. HTTP adapters preserve code as their
2
+ // reason field; their transport envelopes are documented separately.
3
+ // Dependency outages are not verdicts about a person.
4
+ import { type Static, Type } from "@sinclair/typebox";
5
+ import { closed, NonEmptyString, type ProfileEntry } from "../primitives.js";
6
+
7
+ export const REFUSAL_V3_PROFILE = "dsg.core.refusal/3" as const;
8
+
9
+ const RefusalCodeV3SchemaValue = Type.Union([
10
+ Type.Literal("organization_absent"),
11
+ Type.Literal("organization_exists"),
12
+ Type.Literal("domain_mismatch"),
13
+ Type.Literal("suspended"),
14
+ Type.Literal("organization_disabled"),
15
+ Type.Literal("claims_missing"),
16
+ Type.Literal("not_qualified"),
17
+ Type.Literal("subject_conflict"),
18
+ ]);
19
+ export const RefusalCodeV3Schema: typeof RefusalCodeV3SchemaValue = RefusalCodeV3SchemaValue;
20
+ export type RefusalCodeV3 = Static<typeof RefusalCodeV3Schema>;
21
+
22
+ const RefusalStageV3SchemaValue = Type.Union([
23
+ Type.Literal("proxy"),
24
+ Type.Literal("provider"),
25
+ Type.Literal("identity_read"),
26
+ Type.Literal("plane"),
27
+ Type.Literal("console"),
28
+ Type.Literal("kernel"),
29
+ Type.Literal("record"),
30
+ Type.Literal("claim"),
31
+ ]);
32
+ export const RefusalStageV3Schema: typeof RefusalStageV3SchemaValue = RefusalStageV3SchemaValue;
33
+ export type RefusalStageV3 = Static<typeof RefusalStageV3Schema>;
34
+
35
+ const RefusalV3SchemaValue = closed({
36
+ profile: Type.Literal(REFUSAL_V3_PROFILE),
37
+ code: RefusalCodeV3Schema,
38
+ sentence: NonEmptyString,
39
+ stage: Type.Optional(RefusalStageV3Schema),
40
+ correlationId: Type.Optional(NonEmptyString),
41
+ detail: Type.Optional(NonEmptyString),
42
+ });
43
+ export const RefusalV3Schema: typeof RefusalV3SchemaValue = RefusalV3SchemaValue;
44
+ export type RefusalV3 = Static<typeof RefusalV3Schema>;
45
+
46
+ export const refusalV3: ProfileEntry = {
47
+ literal: REFUSAL_V3_PROFILE,
48
+ rootDocument: "refusal",
49
+ documents: { refusal: RefusalV3Schema },
50
+ };
package/src/index.ts CHANGED
@@ -131,13 +131,27 @@ export {
131
131
  export type { RunSummary, RunSummaryDecision } from "./run/run-summary.v1.js";
132
132
  export { REFUSAL_PROFILE, RefusalCodeSchema, RefusalSchema } from "./core/refusal.v1.js";
133
133
  export type { Refusal, RefusalCode } from "./core/refusal.v1.js";
134
- export { REFUSAL_V2_PROFILE, RefusalCodeV2Schema, RefusalV2Schema } from "./core/refusal.v2.js";
135
- export type { RefusalCodeV2, RefusalV2 } from "./core/refusal.v2.js";
136
134
  export {
135
+ REFUSAL_V2_PROFILE,
136
+ RefusalCodeV2Schema,
137
+ RefusalStageV2Schema,
138
+ RefusalV2Schema,
139
+ } from "./core/refusal.v2.js";
140
+ export type { RefusalCodeV2, RefusalStageV2, RefusalV2 } from "./core/refusal.v2.js";
141
+ export {
142
+ GOOGLE_IDENTITY_PROFILE,
137
143
  GOOGLE_SIGN_IN_ISSUER,
138
- IDENTITY_BINDING_PROFILE,
139
- IdentityBindingSchema,
140
- } from "./core/identity-binding.v1.js";
144
+ GoogleIdentitySchema,
145
+ } from "./core/google-identity.v1.js";
146
+ export type { GoogleIdentity } from "./core/google-identity.v1.js";
147
+ export {
148
+ REFUSAL_V3_PROFILE,
149
+ RefusalCodeV3Schema,
150
+ RefusalStageV3Schema,
151
+ RefusalV3Schema,
152
+ } from "./core/refusal.v3.js";
153
+ export type { RefusalCodeV3, RefusalStageV3, RefusalV3 } from "./core/refusal.v3.js";
154
+ export { IDENTITY_BINDING_PROFILE, IdentityBindingSchema } from "./core/identity-binding.v1.js";
141
155
  export type { IdentityBinding } from "./core/identity-binding.v1.js";
142
156
 
143
157
  import type { ProfileEntry } from "./primitives.js";
@@ -149,6 +163,8 @@ import { decisionV1 } from "./run/decision.v1.js";
149
163
  import { runSummaryV1 } from "./run/run-summary.v1.js";
150
164
  import { refusalV1 } from "./core/refusal.v1.js";
151
165
  import { refusalV2 } from "./core/refusal.v2.js";
166
+ import { refusalV3 } from "./core/refusal.v3.js";
167
+ import { googleIdentityV1 } from "./core/google-identity.v1.js";
152
168
  import { identityBindingV1 } from "./core/identity-binding.v1.js";
153
169
  import { signedLawV1 } from "./infra/signed-law.v1.js";
154
170
  import { resourceDescriptorV1 } from "./infra/resource-descriptor.v1.js";
@@ -157,12 +173,11 @@ import { revocationsV1 } from "./registry/revocations.v1.js";
157
173
  import { bootstrapV1 } from "./kernel/bootstrap.v1.js";
158
174
  import { ordinaryAuthorityV1 } from "./kernel/ordinary-authority.v1.js";
159
175
  import { standingOrderActivationV1 } from "./kernel/standing-order-activation.v1.js";
160
-
161
176
  /** Every profile this version of the package defines, keyed by literal.
162
177
  * Profile modules are added here as they are extracted; the rules test
163
178
  * and the schema emitter walk this registry, so a module that is not
164
179
  * registered does not exist. */
165
- export const PROFILES: Readonly<Record<string, ProfileEntry>> = {
180
+ export const PROFILES = {
166
181
  [dispatchConsumeV1.literal]: dispatchConsumeV1,
167
182
  [operationV1.literal]: operationV1,
168
183
  [eventV1.literal]: eventV1,
@@ -171,6 +186,8 @@ export const PROFILES: Readonly<Record<string, ProfileEntry>> = {
171
186
  [runSummaryV1.literal]: runSummaryV1,
172
187
  [refusalV1.literal]: refusalV1,
173
188
  [refusalV2.literal]: refusalV2,
189
+ [refusalV3.literal]: refusalV3,
190
+ [googleIdentityV1.literal]: googleIdentityV1,
174
191
  [identityBindingV1.literal]: identityBindingV1,
175
192
  [signedLawV1.literal]: signedLawV1,
176
193
  [resourceDescriptorV1.literal]: resourceDescriptorV1,
@@ -179,4 +196,4 @@ export const PROFILES: Readonly<Record<string, ProfileEntry>> = {
179
196
  [bootstrapV1.literal]: bootstrapV1,
180
197
  [ordinaryAuthorityV1.literal]: ordinaryAuthorityV1,
181
198
  [standingOrderActivationV1.literal]: standingOrderActivationV1,
182
- };
199
+ } satisfies Readonly<Record<string, ProfileEntry>>;
@@ -42,6 +42,6 @@ export type AdoptionFact = Static<typeof AdoptionFactSchema>;
42
42
 
43
43
  export const adoptionFactV1: ProfileEntry = {
44
44
  literal: ADOPTION_FACT_PROFILE,
45
- rootShape: "fact",
46
- shapes: { fact: AdoptionFactSchema },
45
+ rootDocument: "fact",
46
+ documents: { fact: AdoptionFactSchema },
47
47
  };
@@ -53,6 +53,6 @@ export const resourceDescriptorV1: ProfileEntry = {
53
53
  literal: RESOURCE_DESCRIPTOR_PROFILE,
54
54
  literalNote:
55
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 },
56
+ rootDocument: "descriptor",
57
+ documents: { descriptor: ResourceDescriptorSchema },
58
58
  };
@@ -273,5 +273,5 @@ export const signedLawV1: ProfileEntry = {
273
273
  literal: SIGNED_LAW_PROFILE,
274
274
  literalNote:
275
275
  "carried as the domain member of the canonical signature input, not as a bundle field",
276
- shapes: { bundle: SignedLawBundleSchema },
276
+ documents: { bundle: SignedLawBundleSchema },
277
277
  };
@@ -64,5 +64,5 @@ export type SignedBootstrapIntent = Static<typeof SignedBootstrapIntentSchema>;
64
64
 
65
65
  export const bootstrapV1: ProfileEntry = {
66
66
  literal: BOOTSTRAP_PROFILE,
67
- shapes: { intent: BootstrapIntentSchema, signed: SignedBootstrapIntentSchema },
67
+ documents: { intent: BootstrapIntentSchema, signed: SignedBootstrapIntentSchema },
68
68
  };
@@ -106,7 +106,7 @@ export type DispatchRefusal = Static<typeof DispatchRefusalSchema>;
106
106
 
107
107
  export const dispatchConsumeV1: ProfileEntry = {
108
108
  literal: DISPATCH_CONSUME_PROFILE,
109
- shapes: {
109
+ documents: {
110
110
  request: DispatchConsumeRequestSchema,
111
111
  lease: DispatchLeaseSchema,
112
112
  refusal: DispatchRefusalSchema,
@@ -48,6 +48,6 @@ export type OrdinaryAuthority = Static<typeof OrdinaryAuthoritySchema>;
48
48
 
49
49
  export const ordinaryAuthorityV1: ProfileEntry = {
50
50
  literal: ORDINARY_AUTHORITY_PROFILE,
51
- rootShape: "authority",
52
- shapes: { authority: OrdinaryAuthoritySchema },
51
+ rootDocument: "authority",
52
+ documents: { authority: OrdinaryAuthoritySchema },
53
53
  };
@@ -63,8 +63,8 @@ export type SignedStandingOrderActivation = Static<typeof SignedStandingOrderAct
63
63
 
64
64
  export const standingOrderActivationV1: ProfileEntry = {
65
65
  literal: STANDING_ORDER_ACTIVATION_PROFILE,
66
- rootShape: "event",
67
- shapes: {
66
+ rootDocument: "event",
67
+ documents: {
68
68
  activation: StandingOrderActivationSchema,
69
69
  signed: SignedStandingOrderActivationSchema,
70
70
  event: StandingOrderActivationEventSchema,
package/src/primitives.ts CHANGED
@@ -46,12 +46,12 @@ export const PersonReference = closed({
46
46
  * "lease", "refusal"); vectors address a shape as "<literal>#<shape>". */
47
47
  export type ProfileEntry = {
48
48
  readonly literal: `dsg.${string}.${string}/${number}`;
49
- readonly shapes: Readonly<Record<string, TSchema>>;
49
+ readonly documents: Readonly<Record<string, TSchema>>;
50
50
  /** Set ONLY when the wire cannot carry the literal as a field of any
51
51
  * shape (a frozen /1); names exactly where the literal lives instead. */
52
52
  readonly literalNote?: string;
53
53
  /** Names the shape non-TS consumers validate a whole document against;
54
54
  * the emitted JSON Schema gains a root $ref to it. Only meaningful for
55
55
  * profiles with a single document root. */
56
- readonly rootShape?: string;
56
+ readonly rootDocument?: string;
57
57
  };
@@ -83,5 +83,5 @@ export type RevocationPointer = Static<typeof RevocationPointerSchema>;
83
83
 
84
84
  export const revocationsV1: ProfileEntry = {
85
85
  literal: REVOCATIONS_PROFILE,
86
- shapes: { snapshot: RevocationSchema, pointer: RevocationPointerSchema },
86
+ documents: { snapshot: RevocationSchema, pointer: RevocationPointerSchema },
87
87
  };
@@ -22,6 +22,6 @@ export type RunDecision = Static<typeof RunDecisionSchema>;
22
22
 
23
23
  export const decisionV1: ProfileEntry = {
24
24
  literal: DECISION_PROFILE,
25
- rootShape: "decision",
26
- shapes: { decision: RunDecisionSchema },
25
+ rootDocument: "decision",
26
+ documents: { decision: RunDecisionSchema },
27
27
  };
@@ -90,6 +90,6 @@ export type EventStreamSeal = Static<typeof EventStreamSealSchema>;
90
90
 
91
91
  export const eventV1: ProfileEntry = {
92
92
  literal: EVENT_PROFILE,
93
- rootShape: "event",
94
- shapes: { event: EventSchema, streamSeal: EventStreamSealSchema },
93
+ rootDocument: "event",
94
+ documents: { event: EventSchema, streamSeal: EventStreamSealSchema },
95
95
  };
@@ -150,7 +150,7 @@ export type OperationStatus = Readback;
150
150
 
151
151
  export const operationV1: ProfileEntry = {
152
152
  literal: OPERATION_PROFILE,
153
- shapes: {
153
+ documents: {
154
154
  request: OperationRequestSchema,
155
155
  accepted: AcceptedSchema,
156
156
  readback: ReadbackSchema,
@@ -45,6 +45,6 @@ export type RunRequest = Static<typeof RunRequestSchema>;
45
45
 
46
46
  export const requestV1: ProfileEntry = {
47
47
  literal: REQUEST_PROFILE,
48
- rootShape: "request",
49
- shapes: { request: RunRequestSchema },
48
+ rootDocument: "request",
49
+ documents: { request: RunRequestSchema },
50
50
  };
@@ -37,6 +37,6 @@ export type RunSummary = Static<typeof RunSummarySchema>;
37
37
 
38
38
  export const runSummaryV1: ProfileEntry = {
39
39
  literal: RUN_SUMMARY_PROFILE,
40
- rootShape: "summary",
41
- shapes: { summary: RunSummarySchema },
40
+ rootDocument: "summary",
41
+ documents: { summary: RunSummarySchema },
42
42
  };