@oxyhq/contracts 0.29.0 → 0.31.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.
Files changed (51) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +41 -0
  3. package/dist/cjs/identity.js +33 -1
  4. package/dist/cjs/index.js +35 -7
  5. package/dist/cjs/inference/aliaModelRelease.js +262 -0
  6. package/dist/cjs/inference/catalogue.js +1 -4
  7. package/dist/cjs/inference/identifiers.js +23 -3
  8. package/dist/cjs/inference/modelDocumentation.js +433 -0
  9. package/dist/cjs/inference/providerConnection.js +77 -7
  10. package/dist/cjs/inference/request.js +188 -5
  11. package/dist/cjs/inference/routingPolicy.js +81 -2
  12. package/dist/cjs/inference/streamEvents.js +27 -0
  13. package/dist/cjs/inference/usage.js +32 -1
  14. package/dist/cjs/inference/version.js +15 -2
  15. package/dist/cjs/updates.js +2 -0
  16. package/dist/esm/.tsbuildinfo +1 -1
  17. package/dist/esm/accountGraph.js +41 -0
  18. package/dist/esm/identity.js +32 -0
  19. package/dist/esm/index.js +14 -4
  20. package/dist/esm/inference/aliaModelRelease.js +259 -0
  21. package/dist/esm/inference/catalogue.js +2 -5
  22. package/dist/esm/inference/identifiers.js +22 -2
  23. package/dist/esm/inference/modelDocumentation.js +430 -0
  24. package/dist/esm/inference/providerConnection.js +76 -6
  25. package/dist/esm/inference/request.js +189 -6
  26. package/dist/esm/inference/routingPolicy.js +81 -2
  27. package/dist/esm/inference/streamEvents.js +27 -0
  28. package/dist/esm/inference/usage.js +32 -1
  29. package/dist/esm/inference/version.js +15 -2
  30. package/dist/esm/updates.js +2 -0
  31. package/dist/types/.tsbuildinfo +1 -1
  32. package/dist/types/accountGraph.d.ts +43 -0
  33. package/dist/types/identity.d.ts +59 -1
  34. package/dist/types/index.d.ts +10 -6
  35. package/dist/types/inference/accountBilling.d.ts +26 -26
  36. package/dist/types/inference/aliaModelRelease.d.ts +609 -0
  37. package/dist/types/inference/catalogue.d.ts +6 -6
  38. package/dist/types/inference/entitlement.d.ts +4 -4
  39. package/dist/types/inference/identifiers.d.ts +20 -2
  40. package/dist/types/inference/modelDocumentation.d.ts +1603 -0
  41. package/dist/types/inference/money.d.ts +4 -4
  42. package/dist/types/inference/priceVersion.d.ts +14 -14
  43. package/dist/types/inference/providerConnection.d.ts +37 -8
  44. package/dist/types/inference/request.d.ts +291 -5
  45. package/dist/types/inference/routingPolicy.d.ts +109 -13
  46. package/dist/types/inference/streamEvents.d.ts +53 -26
  47. package/dist/types/inference/usage.d.ts +103 -79
  48. package/dist/types/inference/version.d.ts +15 -2
  49. package/dist/types/keyRecovery.d.ts +4 -4
  50. package/dist/types/updates.d.ts +10 -0
  51. package/package.json +1 -1
@@ -349,4 +349,45 @@ export const createAccountRequestSchema = z.object({
349
349
  description: z.string().trim().max(1000).optional(),
350
350
  /** Ordered, PRIMARY FIRST — see rule 2 above {@link ACCOUNT_CATEGORY_IDS}. */
351
351
  accountCategories: accountCategoriesSchema.optional(),
352
+ /**
353
+ * Create the account already opted OUT of discovery.
354
+ *
355
+ * ## Why this belongs at CREATION and not only on the privacy route
356
+ *
357
+ * Every account is born discoverable: the column defaults to `false` and
358
+ * nothing on the create path wrote it, so a new account appears in people
359
+ * search the instant it exists. For a human signing themselves up that is the
360
+ * right default and it is NOT changed here. For an account a program creates
361
+ * on someone's behalf — an agent, an unlaunched project, an organization for
362
+ * something not yet announced — it publishes the thing before its owner ever
363
+ * decided to.
364
+ *
365
+ * The alternative is a second call right after create, which is a window in
366
+ * which the account IS public, and a window whose closing depends on a second
367
+ * request succeeding. A field here has neither: one statement, one row, born
368
+ * in the state the caller asked for.
369
+ *
370
+ * ## It reuses the existing flag deliberately
371
+ *
372
+ * This is `privacy_is_private_account`, the same one `PUT /users/:id/privacy`
373
+ * toggles — not a new "published" column. A second visibility flag would be a
374
+ * second source of truth for one question, and the two would disagree.
375
+ *
376
+ * Inherited semantics, stated because reusing a flag means inheriting ALL of
377
+ * it: the account is kept out of people search, out of the follow-graph lists
378
+ * (`followers` / `following` / `mutuals`), out of `/similar` and out of the
379
+ * recommendation candidate pools, and its non-public, non-unlisted media
380
+ * becomes follower-gated. It does NOT hide the profile from someone who knows
381
+ * the handle, and it carries NO follow-approval flow — following is immediate
382
+ * and unilateral whatever this says, so nothing here creates a request queue
383
+ * nobody attends.
384
+ *
385
+ * ## Not conditioned on `kind`, on purpose
386
+ *
387
+ * The same reasoning as `accountCategories` above: this object does not
388
+ * refine on kind, and an unlaunched organization has exactly the problem an
389
+ * unpublished agent does. The discovery predicate never reads `kind`, so the
390
+ * remedy must not either.
391
+ */
392
+ isPrivateAccount: z.boolean().optional(),
352
393
  });
@@ -204,6 +204,37 @@ export const exportAttestationSchema = z.object({
204
204
  signature: z.string(),
205
205
  signedAt: z.number(),
206
206
  });
207
+ export const exportUsageReceiptSchema = z.object({
208
+ receiptId: z.string(),
209
+ requestId: z.string(),
210
+ settledAt: z.string(),
211
+ billedAmount: z.string(),
212
+ currency: z.string(),
213
+ outcome: z.string(),
214
+ resolvedModelReference: z.string(),
215
+ servingProvider: z.string(),
216
+ platformFeeOnly: z.boolean(),
217
+ });
218
+ export const exportLedgerEntrySchema = z.object({
219
+ entryId: z.string(),
220
+ kind: z.string(),
221
+ currency: z.string(),
222
+ createdAt: z.string(),
223
+ });
224
+ export const exportUsageReservationSchema = z.object({
225
+ reservationId: z.string(),
226
+ requestId: z.string(),
227
+ status: z.string(),
228
+ reservedAmount: z.string(),
229
+ currency: z.string(),
230
+ createdAt: z.string(),
231
+ expiresAt: z.string(),
232
+ });
233
+ export const exportFinancialSectionSchema = z.object({
234
+ receipts: z.array(exportUsageReceiptSchema),
235
+ ledgerEntries: z.array(exportLedgerEntrySchema),
236
+ reservations: z.array(exportUsageReservationSchema),
237
+ });
207
238
  export const exportBundleSchema = z.object({
208
239
  '$schema': z.string(),
209
240
  exportedAt: z.string(),
@@ -218,6 +249,7 @@ export const exportBundleSchema = z.object({
218
249
  following: z.array(z.string()),
219
250
  followers: z.array(z.string()),
220
251
  }),
252
+ financial: exportFinancialSectionSchema,
221
253
  attestation: exportAttestationSchema.nullable(),
222
254
  proof: exportAttestationSchema.optional(),
223
255
  });
package/dist/esm/index.js CHANGED
@@ -30,7 +30,7 @@ export {
30
30
  recommendationExcludeTypeSchema, recommendationBoostSchema, recommendationSignalWeightsSchema, recommendationRequestSchema, recommendationCountSchema, recommendationItemSchema, recommendationResponseSchema, appEndorsementInputSchema, appInterestInputSchema, appUserSignalIngestSchema, appAffinityEventTypeSchema, appAffinityEventSchema, appAffinityEventsIngestSchema, } from './recommendations.js';
31
31
  export {
32
32
  // Schemas
33
- verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportBundleSchema, } from './identity.js';
33
+ verificationMethodSchema, didServiceSchema, didDocumentSchema, signedRecordEnvelopeSchema, verifiedDomainSchema, domainVerificationRequestSchema, domainVerificationInstructionsSchema, authMethodEntrySchema, authMethodsResponseSchema, exportAttestationSchema, exportUsageReceiptSchema, exportLedgerEntrySchema, exportUsageReservationSchema, exportFinancialSectionSchema, exportBundleSchema, } from './identity.js';
34
34
  export {
35
35
  // Schemas
36
36
  oxySignedRecordTypeSchema, } from './oxyRecordTypes.js';
@@ -113,7 +113,7 @@ export {
113
113
  // are branded apart so a delegated end user can never become the payer.
114
114
  oxyAccountIdSchema, delegatedUserIdSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, generationIdSchema, idempotencyKeySchema, inferenceEnvironmentSchema,
115
115
  // Wire primitives
116
- inferenceTimestampSchema, inferenceDateSchema, inferenceHttpsUrlSchema,
116
+ inferenceTimestampSchema, inferenceDateSchema, inferenceHttpsUrlSchema, sha256DigestSchema,
117
117
  // Catalogue references
118
118
  publisherSlugSchema, modelSlugSchema, modelIdSchema, modelRevisionLabelSchema, modelReferenceSchema, routingProfileSlugSchema, inferenceProviderSlugSchema, deploymentIdSchema, inferenceRegionSchema, RESERVED_ALIA_PUBLISHER, } from './inference/identifiers.js';
119
119
  export {
@@ -134,7 +134,17 @@ inferenceModalitySchema, modelCapabilitiesSchema, modelLicenseSchema, modelProve
134
134
  export {
135
135
  // Routing policy: every control, plus the refinement that rejects a policy
136
136
  // no route could ever satisfy.
137
- routingTargetSchema, routingPolicyScopeSchema, routingFallbackPolicySchema, routingPolicySchema, routingPolicyReferenceSchema, } from './inference/routingPolicy.js';
137
+ routingTargetSchema, routingPolicyScopeSchema, routingFallbackPolicySchema, routingPolicySchema, routingPolicyReferenceSchema,
138
+ // What the data plane actually receives: the routes the policy authorized.
139
+ authorizedRouteSchema, } from './inference/routingPolicy.js';
140
+ export {
141
+ // The signed Alia model release manifest (ingestion contract; no endpoint).
142
+ aliaReleaseArtifactSchema, aliaReleaseSignatureSchema, aliaModelReleaseManifestSchema, } from './inference/aliaModelRelease.js';
143
+ export {
144
+ // Model documentation: the GPAI/EU AI Act record, the ingestion request that
145
+ // accepts it beside a signed manifest, and the revision-scoped documentation
146
+ // view a downstream developer reads.
147
+ modelDistributionMethodSchema, modelSystemicRiskTierSchema, trainingComputeFlopsSchema, SYSTEMIC_RISK_COMPUTE_THRESHOLD_FLOPS, modelDownstreamDocumentationSchema, modelGpaiDocumentationSchema, modelLineDeclarationSchema, modelReleaseIngestionRequestSchema, modelReleaseIngestionResultSchema, modelDocumentationSchema, } from './inference/modelDocumentation.js';
138
148
  export {
139
149
  // The normalized Oxy→data-plane request envelope.
140
150
  inferenceContentSourceSchema, inferenceContentPartSchema, inferenceToolCallSchema, inferenceMessageRoleSchema, inferenceMessageSchema, inferenceInputSchema, samplingParametersSchema, toolDefinitionSchema, toolChoiceSchema, responseFormatSchema, clientRequestMetadataSchema, inferenceRequestSchema, } from './inference/request.js';
@@ -146,7 +156,7 @@ export {
146
156
  usageReservationRequestSchema, usageReservationStatusSchema, usageReservationSchema, inferenceRequestOutcomeSchema, normalizedUsageReportSchema, usageReceiptSchema, usageRefundSubjectSchema, usageRefundReasonSchema, usageRefundSchema, } from './inference/usage.js';
147
157
  export {
148
158
  // BYOK connection metadata that structurally cannot carry a secret.
149
- providerConnectionScopeSchema, providerSecretReferenceSchema, providerConnectionValidationSchema, providerConnectionStatusSchema, providerConnectionSchema, } from './inference/providerConnection.js';
159
+ PROVIDER_SECRET_REFERENCE_NAMESPACE, providerConnectionScopeSchema, providerSecretReferenceSchema, providerConnectionValidationSchema, providerConnectionStatusSchema, providerConnectionSchema, } from './inference/providerConnection.js';
150
160
  export {
151
161
  // Account-scoped billing: who pays, what they hold, what bounds them, and
152
162
  // how it reconciles against the payment processor. A grant and a purchase
@@ -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
+ });
@@ -27,7 +27,7 @@
27
27
  * Decided in: docs/adr/0008-catalogue-concept-separation.md.
28
28
  */
29
29
  import { z } from 'zod';
30
- import { deploymentIdSchema, inferenceDateSchema, inferenceHttpsUrlSchema, inferenceProviderSlugSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelReferenceSchema, modelRevisionLabelSchema, modelSlugSchema, publisherSlugSchema, RESERVED_ALIA_PUBLISHER, routingProfileSlugSchema, } from './identifiers.js';
30
+ import { deploymentIdSchema, inferenceDateSchema, inferenceHttpsUrlSchema, inferenceProviderSlugSchema, inferenceRegionSchema, inferenceTimestampSchema, modelIdSchema, modelReferenceSchema, modelRevisionLabelSchema, modelSlugSchema, publisherSlugSchema, RESERVED_ALIA_PUBLISHER, routingProfileSlugSchema, sha256DigestSchema, } from './identifiers.js';
31
31
  import { priceSnapshotSchema } from './priceVersion.js';
32
32
  /* -------------------------------------------------------------------------- */
33
33
  /* Shared catalogue vocabulary */
@@ -279,10 +279,7 @@ export const modelRevisionSchema = z
279
279
  releasedAt: inferenceTimestampSchema,
280
280
  retiredAt: inferenceTimestampSchema.optional(),
281
281
  /** Digest of the served artifact, where Oxy hosts the weights itself. */
282
- artifactDigest: z
283
- .string()
284
- .regex(/^sha256:[a-f0-9]{64}$/, 'artifact digest must be sha256:<64 lowercase hex>')
285
- .optional(),
282
+ artifactDigest: sha256DigestSchema.optional(),
286
283
  modelCardUrl: inferenceHttpsUrlSchema.optional(),
287
284
  evaluations: z.array(modelEvaluationResultSchema).default([]),
288
285
  safety: modelSafetyMetadataSchema.optional(),
@@ -59,8 +59,16 @@ export const oxyCredentialIdSchema = z.string().min(1).max(64);
59
59
  * traceable as one that was served (ADR 0007, and step 1 of ADR 0010's edge
60
60
  * order). It is required on the inbound envelope, which is what makes the data
61
61
  * plane a consumer of this id rather than its source: the data plane echoes it
62
- * on every stream event, on the usage report and on anything it can be asked
63
- * about later.
62
+ * on every stream event, on the usage report, in its response header and on
63
+ * anything it can be asked about later. It never mints one for a request it
64
+ * received.
65
+ *
66
+ * The one case that is NOT an exception to that: an envelope the data plane
67
+ * cannot read or authenticate carries no id to echo, so its rejection is
68
+ * labelled with an id of the data plane's own — visibly local, and never
69
+ * correlated with an Oxy request, because there is no Oxy request it belongs to.
70
+ * Saying so is what stops "consumer, not source" from being read as forbidding
71
+ * the only id such a rejection could have.
64
72
  *
65
73
  * Correlates the Oxy edge, the data plane, the financial ledger and the
66
74
  * customer-visible receipt, so it appears on every stream event and every
@@ -106,6 +114,18 @@ export const inferenceHttpsUrlSchema = z
106
114
  .string()
107
115
  .max(2048)
108
116
  .regex(/^https:\/\/[^\s]+$/, 'must be an absolute https URL');
117
+ /**
118
+ * A content digest, `sha256:<64 lowercase hex>`.
119
+ *
120
+ * ONE spelling, because a digest is compared for equality and nothing else: an
121
+ * uppercase or unprefixed variant of the same hash is a different string, so two
122
+ * records describing the same bytes would not match. Lowercase hex with the
123
+ * algorithm prefix is what the `inference_model_revisions` CHECK stores and what
124
+ * every artifact registry emits.
125
+ */
126
+ export const sha256DigestSchema = z
127
+ .string()
128
+ .regex(/^sha256:[a-f0-9]{64}$/, 'digest must be sha256:<64 lowercase hex>');
109
129
  /* -------------------------------------------------------------------------- */
110
130
  /* Catalogue references */
111
131
  /* -------------------------------------------------------------------------- */