@oxy.so/contracts 1.0.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/LICENSE +202 -0
- package/NOTICE +16 -0
- package/dist/cjs/.tsbuildinfo +1 -0
- package/dist/cjs/accountGraph.js +489 -0
- package/dist/cjs/agency.js +439 -0
- package/dist/cjs/browserHub.js +215 -0
- package/dist/cjs/civic.js +163 -0
- package/dist/cjs/commonsSignIn.js +59 -0
- package/dist/cjs/deviceBoot.js +50 -0
- package/dist/cjs/deviceDirectory.js +189 -0
- package/dist/cjs/devicePairing.js +138 -0
- package/dist/cjs/deviceSession.js +164 -0
- package/dist/cjs/emailAgentContext.js +32 -0
- package/dist/cjs/followGraph.js +28 -0
- package/dist/cjs/identity.js +258 -0
- package/dist/cjs/inboxPush.js +24 -0
- package/dist/cjs/index.js +618 -0
- package/dist/cjs/inference/accountBilling.js +334 -0
- package/dist/cjs/inference/aliaModelRelease.js +262 -0
- package/dist/cjs/inference/attribution.js +106 -0
- package/dist/cjs/inference/catalogue.js +487 -0
- package/dist/cjs/inference/entitlement.js +217 -0
- package/dist/cjs/inference/errors.js +309 -0
- package/dist/cjs/inference/identifiers.js +224 -0
- package/dist/cjs/inference/inbox.js +105 -0
- package/dist/cjs/inference/modelDocumentation.js +433 -0
- package/dist/cjs/inference/money.js +188 -0
- package/dist/cjs/inference/priceVersion.js +110 -0
- package/dist/cjs/inference/providerConnection.js +455 -0
- package/dist/cjs/inference/request.js +477 -0
- package/dist/cjs/inference/routingPolicy.js +318 -0
- package/dist/cjs/inference/streamEvents.js +258 -0
- package/dist/cjs/inference/usage.js +329 -0
- package/dist/cjs/inference/version.js +105 -0
- package/dist/cjs/keyRecovery.js +91 -0
- package/dist/cjs/keyRotation.js +75 -0
- package/dist/cjs/links.js +68 -0
- package/dist/cjs/moderationReputation.js +298 -0
- package/dist/cjs/oauth.js +66 -0
- package/dist/cjs/oxyRecordTypes.js +71 -0
- package/dist/cjs/protocol.js +53 -0
- package/dist/cjs/recommendations.js +168 -0
- package/dist/cjs/reputation.js +297 -0
- package/dist/cjs/sessionStatus.js +121 -0
- package/dist/cjs/transparency.js +89 -0
- package/dist/cjs/updates.js +252 -0
- package/dist/cjs/userInvalidation.js +89 -0
- package/dist/cjs/userResponse.js +245 -0
- package/dist/cjs/username.js +290 -0
- package/dist/cjs/webauthn.js +71 -0
- package/dist/esm/.tsbuildinfo +1 -0
- package/dist/esm/accountGraph.js +480 -0
- package/dist/esm/agency.js +436 -0
- package/dist/esm/browserHub.js +212 -0
- package/dist/esm/civic.js +160 -0
- package/dist/esm/commonsSignIn.js +56 -0
- package/dist/esm/deviceBoot.js +47 -0
- package/dist/esm/deviceDirectory.js +186 -0
- package/dist/esm/devicePairing.js +135 -0
- package/dist/esm/deviceSession.js +161 -0
- package/dist/esm/emailAgentContext.js +29 -0
- package/dist/esm/followGraph.js +27 -0
- package/dist/esm/identity.js +255 -0
- package/dist/esm/inboxPush.js +21 -0
- package/dist/esm/index.js +172 -0
- package/dist/esm/inference/accountBilling.js +331 -0
- package/dist/esm/inference/aliaModelRelease.js +259 -0
- package/dist/esm/inference/attribution.js +103 -0
- package/dist/esm/inference/catalogue.js +484 -0
- package/dist/esm/inference/entitlement.js +214 -0
- package/dist/esm/inference/errors.js +306 -0
- package/dist/esm/inference/identifiers.js +221 -0
- package/dist/esm/inference/inbox.js +102 -0
- package/dist/esm/inference/modelDocumentation.js +430 -0
- package/dist/esm/inference/money.js +185 -0
- package/dist/esm/inference/priceVersion.js +107 -0
- package/dist/esm/inference/providerConnection.js +452 -0
- package/dist/esm/inference/request.js +474 -0
- package/dist/esm/inference/routingPolicy.js +315 -0
- package/dist/esm/inference/streamEvents.js +255 -0
- package/dist/esm/inference/usage.js +326 -0
- package/dist/esm/inference/version.js +102 -0
- package/dist/esm/keyRecovery.js +88 -0
- package/dist/esm/keyRotation.js +72 -0
- package/dist/esm/links.js +65 -0
- package/dist/esm/moderationReputation.js +295 -0
- package/dist/esm/oauth.js +63 -0
- package/dist/esm/oxyRecordTypes.js +68 -0
- package/dist/esm/protocol.js +50 -0
- package/dist/esm/recommendations.js +165 -0
- package/dist/esm/reputation.js +293 -0
- package/dist/esm/sessionStatus.js +118 -0
- package/dist/esm/transparency.js +86 -0
- package/dist/esm/updates.js +249 -0
- package/dist/esm/userInvalidation.js +85 -0
- package/dist/esm/userResponse.js +240 -0
- package/dist/esm/username.js +283 -0
- package/dist/esm/webauthn.js +68 -0
- package/dist/types/.tsbuildinfo +1 -0
- package/dist/types/accountGraph.d.ts +378 -0
- package/dist/types/agency.d.ts +2162 -0
- package/dist/types/browserHub.d.ts +856 -0
- package/dist/types/civic.d.ts +338 -0
- package/dist/types/commonsSignIn.d.ts +58 -0
- package/dist/types/deviceBoot.d.ts +74 -0
- package/dist/types/deviceDirectory.d.ts +1317 -0
- package/dist/types/devicePairing.d.ts +130 -0
- package/dist/types/deviceSession.d.ts +411 -0
- package/dist/types/emailAgentContext.d.ts +248 -0
- package/dist/types/followGraph.d.ts +150 -0
- package/dist/types/identity.d.ts +402 -0
- package/dist/types/inboxPush.d.ts +30 -0
- package/dist/types/index.d.ts +100 -0
- package/dist/types/inference/accountBilling.d.ts +738 -0
- package/dist/types/inference/aliaModelRelease.d.ts +609 -0
- package/dist/types/inference/attribution.d.ts +176 -0
- package/dist/types/inference/catalogue.d.ts +1618 -0
- package/dist/types/inference/entitlement.d.ts +519 -0
- package/dist/types/inference/errors.d.ts +242 -0
- package/dist/types/inference/identifiers.d.ts +182 -0
- package/dist/types/inference/inbox.d.ts +374 -0
- package/dist/types/inference/modelDocumentation.d.ts +1603 -0
- package/dist/types/inference/money.d.ts +185 -0
- package/dist/types/inference/priceVersion.d.ts +182 -0
- package/dist/types/inference/providerConnection.d.ts +968 -0
- package/dist/types/inference/request.d.ts +2800 -0
- package/dist/types/inference/routingPolicy.d.ts +616 -0
- package/dist/types/inference/streamEvents.d.ts +950 -0
- package/dist/types/inference/usage.d.ts +1164 -0
- package/dist/types/inference/version.d.ts +102 -0
- package/dist/types/keyRecovery.d.ts +138 -0
- package/dist/types/keyRotation.d.ts +103 -0
- package/dist/types/links.d.ts +96 -0
- package/dist/types/moderationReputation.d.ts +487 -0
- package/dist/types/oauth.d.ts +86 -0
- package/dist/types/oxyRecordTypes.d.ts +62 -0
- package/dist/types/protocol.d.ts +86 -0
- package/dist/types/recommendations.d.ts +542 -0
- package/dist/types/reputation.d.ts +457 -0
- package/dist/types/sessionStatus.d.ts +231 -0
- package/dist/types/transparency.d.ts +392 -0
- package/dist/types/updates.d.ts +545 -0
- package/dist/types/userInvalidation.d.ts +94 -0
- package/dist/types/userResponse.d.ts +1706 -0
- package/dist/types/username.d.ts +265 -0
- package/dist/types/webauthn.d.ts +77 -0
- package/package.json +87 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed Alia model release manifest — the ingestion contract for a
|
|
3
|
+
* first-party model release.
|
|
4
|
+
*
|
|
5
|
+
* The catalogue already STORES everything such a manifest carries: the model
|
|
6
|
+
* card, the licence block, the provenance and base model, the evaluation table,
|
|
7
|
+
* the safety metadata, and an artifact digest with a `sha256:<64 hex>` CHECK.
|
|
8
|
+
* What did not exist was the manifest itself — a single document Alia SIGNS,
|
|
9
|
+
* asserting all of it at once — and that is the gap this shape closes. Nothing
|
|
10
|
+
* here re-declares a catalogue field; the manifest COMPOSES the published shapes
|
|
11
|
+
* so a manifest and the catalogue row it produces cannot describe a release
|
|
12
|
+
* differently.
|
|
13
|
+
*
|
|
14
|
+
* ## The manifest tightens the revision it carries
|
|
15
|
+
*
|
|
16
|
+
* `modelRevisionSchema` makes `modelCardUrl`, `artifactDigest`, `evaluations`
|
|
17
|
+
* and `safety` optional, because a third-party route legitimately has none of
|
|
18
|
+
* them — Oxy did not train those weights and cannot publish a card for them. A
|
|
19
|
+
* FIRST-PARTY release has no such excuse: the documentation trail is the reason
|
|
20
|
+
* a release manifest exists at all, and a model Alia ships without one is not a
|
|
21
|
+
* release, it is a deployment. So the refinement below requires all four,
|
|
22
|
+
* without changing the catalogue shape that a third-party entry still parses
|
|
23
|
+
* through.
|
|
24
|
+
*
|
|
25
|
+
* ## `.strict()` at the top level, and here that is forced rather than chosen
|
|
26
|
+
*
|
|
27
|
+
* The shapes exchanged with the data plane tolerate an unknown field, because
|
|
28
|
+
* refusing a producer one minor version ahead is a worse failure than ignoring
|
|
29
|
+
* its addition (`version.ts`). A SIGNED document inverts that: the signature is
|
|
30
|
+
* over the canonical bytes of the manifest, so a field silently stripped at this
|
|
31
|
+
* parse is a field missing from the bytes Oxy re-canonicalizes, and verification
|
|
32
|
+
* fails. A tolerant parse would therefore report "the signature is invalid" for
|
|
33
|
+
* what is really "this build does not understand this manifest" — the wrong
|
|
34
|
+
* diagnosis of the right problem. Strict says the true thing, and the cost is
|
|
35
|
+
* bounded: ingestion is a release-time operation an operator retries once Oxy
|
|
36
|
+
* takes the newer contract, not a served request that becomes unsettleable.
|
|
37
|
+
*
|
|
38
|
+
* ## The ingestion path, which this file used to say did not exist
|
|
39
|
+
*
|
|
40
|
+
* It does now: `POST /inference/admin/model-releases`, defined by
|
|
41
|
+
* `modelReleaseIngestionRequestSchema` in `modelDocumentation.ts`. This shape is
|
|
42
|
+
* unchanged — the request COMPOSES it, alongside two records that are Oxy's own
|
|
43
|
+
* rather than the signer's (the GPAI documentation and the capability sheet a
|
|
44
|
+
* manifest does not carry), precisely so the bytes a signature covers stay
|
|
45
|
+
* exactly the bytes described here.
|
|
46
|
+
*
|
|
47
|
+
* The earlier objection was that a staff write path into an empty catalogue is
|
|
48
|
+
* an unexercised hazard. What answers it is containment rather than emptiness: an
|
|
49
|
+
* ingested revision lands with `is_current = false` and no deployment, so nothing
|
|
50
|
+
* it creates is servable or listed, and a route still needs an approved
|
|
51
|
+
* contract/legal review before any customer can select it.
|
|
52
|
+
*
|
|
53
|
+
* ## What is deliberately NOT here
|
|
54
|
+
*
|
|
55
|
+
* **No `payloadDigest` field.** The signature is over the canonical
|
|
56
|
+
* serialization of this manifest with `signatures` removed, and a verifier
|
|
57
|
+
* recomputes it. Storing the digest beside the document it digests would be a
|
|
58
|
+
* second source of truth for one fact, and a verifier that compared the
|
|
59
|
+
* signature against the DECLARED digest rather than the recomputed one would
|
|
60
|
+
* verify nothing at all.
|
|
61
|
+
*
|
|
62
|
+
* **No verification RESULT.** Whether a signature checked out is Oxy's finding
|
|
63
|
+
* about the document, not a claim the document makes about itself; a `verified`
|
|
64
|
+
* field inside a signed manifest is the signer asserting its own signature.
|
|
65
|
+
*
|
|
66
|
+
* ## The open owner decision this shape does not take
|
|
67
|
+
*
|
|
68
|
+
* **What signs, and what verifies, is not decided.** Oxy holds no Alia signing
|
|
69
|
+
* key, and whether to resolve `keyId` through the existing attestation machinery
|
|
70
|
+
* (`services/oxyVerificationResolver.ts`, the civic attestation code) or to
|
|
71
|
+
* introduce a dedicated Alia release key is a real choice with different
|
|
72
|
+
* custody, rotation and revocation consequences. So `keyId` is an OPAQUE
|
|
73
|
+
* identifier and this file names no registry that resolves it: either answer
|
|
74
|
+
* fits, and neither is presupposed. Until it is answered a manifest can be
|
|
75
|
+
* parsed and cannot be VERIFIED, so the ingestion path records no verification
|
|
76
|
+
* finding at all: it stores the signatures and the manifest as received, and the
|
|
77
|
+
* authority for the ingest is the staff member who performed it. A nullable
|
|
78
|
+
* `verified` column nothing ever writes would read, to whoever scanned the table
|
|
79
|
+
* later, as a check that ran.
|
|
80
|
+
*
|
|
81
|
+
* Decided in: docs/adr/0008-catalogue-concept-separation.md,
|
|
82
|
+
* docs/adr/0017-authorized-routes-in-the-envelope.md, issue #972 §12.
|
|
83
|
+
*/
|
|
84
|
+
import { z } from 'zod';
|
|
85
|
+
import { modelLicenseSchema, modelProvenanceSchema, modelRevisionSchema, } from './catalogue.js';
|
|
86
|
+
import { inferenceTimestampSchema, RESERVED_ALIA_PUBLISHER, sha256DigestSchema, } from './identifiers.js';
|
|
87
|
+
/**
|
|
88
|
+
* One artifact of a release, by path and digest.
|
|
89
|
+
*
|
|
90
|
+
* `sizeBytes` is required beside the digest so a verifier can refuse a stream
|
|
91
|
+
* that is the wrong length before reading it to the end, rather than only after.
|
|
92
|
+
*/
|
|
93
|
+
export const aliaReleaseArtifactSchema = z
|
|
94
|
+
.object({
|
|
95
|
+
/** Path within the release, e.g. `model-00001-of-00004.safetensors`. */
|
|
96
|
+
path: z.string().min(1).max(512),
|
|
97
|
+
digest: sha256DigestSchema,
|
|
98
|
+
sizeBytes: z.number().int().positive().safe(),
|
|
99
|
+
mediaType: z.string().min(1).max(255).optional(),
|
|
100
|
+
})
|
|
101
|
+
.strict();
|
|
102
|
+
/**
|
|
103
|
+
* One detached signature over the manifest.
|
|
104
|
+
*
|
|
105
|
+
* `algorithm` is a CLOSED enum with one member, and both halves of that are
|
|
106
|
+
* deliberate. Closed, because a verifier that trusts a document's own algorithm
|
|
107
|
+
* name accepts whatever that document nominates, `none` included. One member,
|
|
108
|
+
* because Ed25519 is the scheme ADR 0012 already chose for asymmetric
|
|
109
|
+
* verification on this platform, and naming a scheme nothing here can check
|
|
110
|
+
* would be advertising a capability that does not exist. A second member lands
|
|
111
|
+
* when a verifier for it does — which is a closed enum gaining a member, and
|
|
112
|
+
* therefore a MINOR contract-set change the handshake surfaces (`version.ts`).
|
|
113
|
+
*
|
|
114
|
+
* `keyId` is opaque on purpose: see the header. It identifies the public key
|
|
115
|
+
* without saying what resolves it.
|
|
116
|
+
*
|
|
117
|
+
* The signature covers the canonical serialization (RFC 8785 JCS) of the
|
|
118
|
+
* manifest with `signatures` removed. The canonicalization is NAMED rather than
|
|
119
|
+
* left implicit because a digest over "the manifest" is not verifiable by two
|
|
120
|
+
* implementations that serialize JSON differently; naming it is a mechanical
|
|
121
|
+
* necessity and is independent of the open question of which key signs.
|
|
122
|
+
*/
|
|
123
|
+
export const aliaReleaseSignatureSchema = z
|
|
124
|
+
.object({
|
|
125
|
+
algorithm: z.enum(['ed25519']),
|
|
126
|
+
canonicalization: z.enum(['jcs']),
|
|
127
|
+
/** Opaque identifier of the public key. Resolving it is undecided. */
|
|
128
|
+
keyId: z.string().min(1).max(256),
|
|
129
|
+
/**
|
|
130
|
+
* Unpadded base64url. Exactly 86 characters, which is a 64-byte Ed25519
|
|
131
|
+
* signature — the one algorithm above. A second algorithm moves this length
|
|
132
|
+
* into a refinement keyed on `algorithm`.
|
|
133
|
+
*/
|
|
134
|
+
signature: z
|
|
135
|
+
.string()
|
|
136
|
+
.regex(/^[A-Za-z0-9_-]{86}$/, 'signature must be a 64-byte ed25519 signature in unpadded base64url'),
|
|
137
|
+
signedAt: inferenceTimestampSchema,
|
|
138
|
+
})
|
|
139
|
+
.strict();
|
|
140
|
+
/**
|
|
141
|
+
* A signed release of an `alia/*` model revision.
|
|
142
|
+
*
|
|
143
|
+
* `signatures` is a LIST rather than one signature, because "what signs" is
|
|
144
|
+
* undecided: a single field would presuppose one signer, while a list lets an
|
|
145
|
+
* Alia release key and an existing attestation co-sign the same document without
|
|
146
|
+
* either being retrofitted later.
|
|
147
|
+
*/
|
|
148
|
+
export const aliaModelReleaseManifestSchema = z
|
|
149
|
+
.object({
|
|
150
|
+
/** See `version.ts`: an ingestion payload is a whole message on the wire. */
|
|
151
|
+
schemaVersion: z.literal(1),
|
|
152
|
+
/** The release's own identity, so ingestion is idempotent on it. */
|
|
153
|
+
releaseId: z.string().min(1).max(128),
|
|
154
|
+
issuedAt: inferenceTimestampSchema,
|
|
155
|
+
/**
|
|
156
|
+
* The revision being released. Carries its OWN `schemaVersion`, like
|
|
157
|
+
* `billingProfileSchema` inside `accountBillingStateSchema`: the manifest's
|
|
158
|
+
* version governs the manifest and the revision's governs the revision,
|
|
159
|
+
* which is two versions of two things rather than two versions of one.
|
|
160
|
+
*/
|
|
161
|
+
revision: modelRevisionSchema,
|
|
162
|
+
/** On the MODEL rather than the revision in the catalogue, so carried here. */
|
|
163
|
+
provenance: modelProvenanceSchema,
|
|
164
|
+
license: modelLicenseSchema,
|
|
165
|
+
artifacts: z.array(aliaReleaseArtifactSchema).min(1),
|
|
166
|
+
signatures: z.array(aliaReleaseSignatureSchema).min(1),
|
|
167
|
+
})
|
|
168
|
+
.strict()
|
|
169
|
+
.superRefine((manifest, ctx) => {
|
|
170
|
+
// The same rule `catalogueModelSchema` enforces on a model, applied to the
|
|
171
|
+
// carrier that creates one: `alia/*` names models Alia actually owns or
|
|
172
|
+
// derived, and a manifest is the document that would launder somebody else's
|
|
173
|
+
// weights into the namespace.
|
|
174
|
+
const publisher = manifest.revision.modelId.slice(0, manifest.revision.modelId.indexOf('/'));
|
|
175
|
+
if (publisher !== RESERVED_ALIA_PUBLISHER) {
|
|
176
|
+
ctx.addIssue({
|
|
177
|
+
code: z.ZodIssueCode.custom,
|
|
178
|
+
path: ['revision', 'modelId'],
|
|
179
|
+
message: `an Alia release manifest releases a ${RESERVED_ALIA_PUBLISHER}/* model`,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (manifest.provenance.releaseKind !== 'first_party_original' &&
|
|
183
|
+
manifest.provenance.releaseKind !== 'first_party_derived') {
|
|
184
|
+
ctx.addIssue({
|
|
185
|
+
code: z.ZodIssueCode.custom,
|
|
186
|
+
path: ['provenance', 'releaseKind'],
|
|
187
|
+
message: 'an Alia release manifest describes a first-party release',
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// A derived model's base is the licence-attribution trail. Recording the
|
|
191
|
+
// derivation without naming what it derives from loses exactly the fact
|
|
192
|
+
// attribution needs.
|
|
193
|
+
if (manifest.provenance.releaseKind === 'first_party_derived' &&
|
|
194
|
+
manifest.provenance.baseModelId === undefined) {
|
|
195
|
+
ctx.addIssue({
|
|
196
|
+
code: z.ZodIssueCode.custom,
|
|
197
|
+
path: ['provenance', 'baseModelId'],
|
|
198
|
+
message: 'a derived release names the model it derives from',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// The four fields a third-party catalogue entry may omit and a first-party
|
|
202
|
+
// release may not. See the header.
|
|
203
|
+
if (manifest.revision.modelCardUrl === undefined) {
|
|
204
|
+
ctx.addIssue({
|
|
205
|
+
code: z.ZodIssueCode.custom,
|
|
206
|
+
path: ['revision', 'modelCardUrl'],
|
|
207
|
+
message: 'a first-party release publishes a model card',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (manifest.revision.safety === undefined) {
|
|
211
|
+
ctx.addIssue({
|
|
212
|
+
code: z.ZodIssueCode.custom,
|
|
213
|
+
path: ['revision', 'safety'],
|
|
214
|
+
message: 'a first-party release publishes its safety metadata',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (manifest.revision.evaluations.length === 0) {
|
|
218
|
+
ctx.addIssue({
|
|
219
|
+
code: z.ZodIssueCode.custom,
|
|
220
|
+
path: ['revision', 'evaluations'],
|
|
221
|
+
message: 'a first-party release publishes at least one evaluation result',
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// The digest the catalogue will serve has to be one of the digests this
|
|
225
|
+
// manifest signed. Otherwise the signature covers a set of artifacts that
|
|
226
|
+
// does not include the weights anybody runs.
|
|
227
|
+
if (manifest.revision.artifactDigest === undefined) {
|
|
228
|
+
ctx.addIssue({
|
|
229
|
+
code: z.ZodIssueCode.custom,
|
|
230
|
+
path: ['revision', 'artifactDigest'],
|
|
231
|
+
message: 'a first-party release names the digest of the artifact it serves',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else if (!manifest.artifacts.some((artifact) => artifact.digest === manifest.revision.artifactDigest)) {
|
|
235
|
+
ctx.addIssue({
|
|
236
|
+
code: z.ZodIssueCode.custom,
|
|
237
|
+
path: ['revision', 'artifactDigest'],
|
|
238
|
+
message: 'the served artifact digest must appear among the signed artifacts',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const paths = manifest.artifacts.map((artifact) => artifact.path);
|
|
242
|
+
if (new Set(paths).size !== paths.length) {
|
|
243
|
+
ctx.addIssue({
|
|
244
|
+
code: z.ZodIssueCode.custom,
|
|
245
|
+
path: ['artifacts'],
|
|
246
|
+
message: 'each artifact path appears once in a release',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
// Two signatures from one key are one signature written twice, and a
|
|
250
|
+
// duplicate would make a "two independent signers" check pass on one signer.
|
|
251
|
+
const keyIds = manifest.signatures.map((signature) => signature.keyId);
|
|
252
|
+
if (new Set(keyIds).size !== keyIds.length) {
|
|
253
|
+
ctx.addIssue({
|
|
254
|
+
code: z.ZodIssueCode.custom,
|
|
255
|
+
path: ['signatures'],
|
|
256
|
+
message: 'each signing key signs a manifest once',
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical attribution for an inference request.
|
|
3
|
+
*
|
|
4
|
+
* Every accepted request resolves to an Oxy account, an Oxy application, the
|
|
5
|
+
* Oxy credential that authenticated it, an optional delegated end user, and the
|
|
6
|
+
* ids that correlate it across the edge, the data plane and the ledger. The
|
|
7
|
+
* data plane may store these as immutable references; it never owns or mutates
|
|
8
|
+
* them, and it never mints a customer identity of its own.
|
|
9
|
+
*
|
|
10
|
+
* The rule this file encodes structurally, rather than restating in prose:
|
|
11
|
+
* **the delegated `userId` can never be the billing identity.** Two independent
|
|
12
|
+
* mechanisms enforce it, one at compile time and one at parse time, because a
|
|
13
|
+
* delegated identity being charged for somebody else's workload is the kind of
|
|
14
|
+
* mistake that produces a correct-looking invoice for the wrong customer:
|
|
15
|
+
*
|
|
16
|
+
* 1. `accountId` and `userId` carry DIFFERENT brands, so neither is assignable
|
|
17
|
+
* to the other in any consumer without a cast.
|
|
18
|
+
* 2. {@link billingPrincipalSchema} is `.strict()` and holds exactly one field,
|
|
19
|
+
* so a payload that smuggles `userId` into the billing block is rejected at
|
|
20
|
+
* the parse rather than stripped and forgotten.
|
|
21
|
+
*
|
|
22
|
+
* These shapes are EMBEDDED — they ride inside a request envelope, a receipt or
|
|
23
|
+
* a ledger record and inherit its `schemaVersion`. Versioning them separately
|
|
24
|
+
* would let one message claim two versions.
|
|
25
|
+
*
|
|
26
|
+
* Decided in: docs/adr/0007-canonical-request-attribution.md.
|
|
27
|
+
*/
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
import { delegatedUserIdSchema, generationIdSchema, inferenceEnvironmentSchema, oxyAccountIdSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from './identifiers.js';
|
|
30
|
+
/**
|
|
31
|
+
* The inference capability scopes the data plane needs to know about.
|
|
32
|
+
*
|
|
33
|
+
* A credential may carry many other Oxy scopes; only these cross the boundary,
|
|
34
|
+
* because the data plane's authorization questions are exactly "may this caller
|
|
35
|
+
* invoke", "may it read the catalogue", "may it read usage", "may it read or
|
|
36
|
+
* write routing", "may it read or write provider connections". Everything else
|
|
37
|
+
* is the control plane's business and is not the data plane's to hold.
|
|
38
|
+
*/
|
|
39
|
+
export const INFERENCE_SCOPES = [
|
|
40
|
+
'inference:invoke',
|
|
41
|
+
'inference:models:read',
|
|
42
|
+
'inference:usage:read',
|
|
43
|
+
'inference:routing:read',
|
|
44
|
+
'inference:routing:write',
|
|
45
|
+
'inference:providers:read',
|
|
46
|
+
'inference:providers:write',
|
|
47
|
+
];
|
|
48
|
+
export const inferenceScopeSchema = z.enum(INFERENCE_SCOPES);
|
|
49
|
+
/**
|
|
50
|
+
* The financially responsible principal, and the ONLY identity a charge may be
|
|
51
|
+
* booked against.
|
|
52
|
+
*
|
|
53
|
+
* It is its own type — not a field on a larger principal object — precisely so
|
|
54
|
+
* that a function taking "who pays" cannot be handed a user, a session, a
|
|
55
|
+
* device or an application. It cannot be constructed from a delegated user id:
|
|
56
|
+
* the brands differ, and this object accepts no other key.
|
|
57
|
+
*/
|
|
58
|
+
export const billingPrincipalSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
accountId: oxyAccountIdSchema,
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
63
|
+
/**
|
|
64
|
+
* Who authenticated, as resolved by the Oxy edge before a request is forwarded.
|
|
65
|
+
*
|
|
66
|
+
* Mirrors what a verified Oxy service token carries (`appId`, `credentialId`,
|
|
67
|
+
* `ownerAccountId`, `environment`, effective scopes) so that the two
|
|
68
|
+
* authentication paths — a machine API key and a first-party service token —
|
|
69
|
+
* produce one shape downstream. The data plane authorizes against this
|
|
70
|
+
* envelope; it does not re-derive access from its own database, because it has
|
|
71
|
+
* no account graph to re-derive it from.
|
|
72
|
+
*/
|
|
73
|
+
export const authenticatedPrincipalSchema = z.object({
|
|
74
|
+
billing: billingPrincipalSchema,
|
|
75
|
+
applicationId: oxyApplicationIdSchema,
|
|
76
|
+
credentialId: oxyCredentialIdSchema,
|
|
77
|
+
environment: inferenceEnvironmentSchema,
|
|
78
|
+
inferenceScopes: z.array(inferenceScopeSchema),
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* The attribution block carried by every request, receipt and ledger record.
|
|
82
|
+
*
|
|
83
|
+
* `userId` is the OPTIONAL delegated end user — Alia's `X-Oxy-User-Id`. It is
|
|
84
|
+
* attribution only: it never changes which account is charged, never grants
|
|
85
|
+
* access, and lives outside {@link billingPrincipalSchema} so that no code path
|
|
86
|
+
* can read it as the payer.
|
|
87
|
+
*
|
|
88
|
+
* `requestId` is generated by the OXY EDGE, on admission and before
|
|
89
|
+
* authentication completes, and is always present (ADR 0007). Not by the data
|
|
90
|
+
* plane: a data plane that minted the correlation key could not correlate a
|
|
91
|
+
* request it never received, and the requests rejected at the edge are exactly
|
|
92
|
+
* the ones an operator most needs to find.
|
|
93
|
+
*
|
|
94
|
+
* `generationId` is present once a generation exists, which is why it is
|
|
95
|
+
* optional on a request and expected on a receipt. That one IS the data plane's,
|
|
96
|
+
* because only the data plane knows how many outputs a request produced.
|
|
97
|
+
*/
|
|
98
|
+
export const inferenceAttributionSchema = z.object({
|
|
99
|
+
principal: authenticatedPrincipalSchema,
|
|
100
|
+
userId: delegatedUserIdSchema.optional(),
|
|
101
|
+
requestId: requestIdSchema,
|
|
102
|
+
generationId: generationIdSchema.optional(),
|
|
103
|
+
});
|