@independo/inderun-contracts 0.3.3 → 0.4.0-rc.2

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 (41) hide show
  1. package/dist/generated/execution-provenance.d.ts +95 -0
  2. package/dist/generated/execution-provenance.d.ts.map +1 -0
  3. package/dist/generated/execution-provenance.js +2 -0
  4. package/dist/generated/inderun-error.d.ts +102 -0
  5. package/dist/generated/inderun-error.d.ts.map +1 -1
  6. package/dist/generated/index.d.ts +1 -0
  7. package/dist/generated/index.d.ts.map +1 -1
  8. package/dist/generated/route-plan.d.ts +5 -3
  9. package/dist/generated/route-plan.d.ts.map +1 -1
  10. package/dist/generated/route-planner-input.d.ts +26 -0
  11. package/dist/generated/route-planner-input.d.ts.map +1 -1
  12. package/dist/generated/schemas.d.ts +169 -2
  13. package/dist/generated/schemas.d.ts.map +1 -1
  14. package/dist/generated/schemas.js +214 -2
  15. package/dist/generated/stream-event.d.ts +109 -0
  16. package/dist/generated/stream-event.d.ts.map +1 -1
  17. package/dist/generated/stream-terminal-outcome.d.ts +108 -0
  18. package/dist/generated/stream-terminal-outcome.d.ts.map +1 -1
  19. package/dist/generated/task-request.d.ts +8 -0
  20. package/dist/generated/task-request.d.ts.map +1 -1
  21. package/dist/generated/task-result.d.ts +114 -6
  22. package/dist/generated/task-result.d.ts.map +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -2
  26. package/dist/validators.d.ts +3 -0
  27. package/dist/validators.d.ts.map +1 -1
  28. package/dist/validators.js +12 -1
  29. package/package.json +1 -1
  30. package/src/generated/execution-provenance.ts +102 -0
  31. package/src/generated/inderun-error.ts +108 -0
  32. package/src/generated/index.ts +1 -0
  33. package/src/generated/route-plan.ts +5 -3
  34. package/src/generated/route-planner-input.ts +27 -0
  35. package/src/generated/schemas.ts +215 -2
  36. package/src/generated/stream-event.ts +122 -7
  37. package/src/generated/stream-terminal-outcome.ts +114 -0
  38. package/src/generated/task-request.ts +8 -0
  39. package/src/generated/task-result.ts +121 -7
  40. package/src/index.ts +3 -0
  41. package/src/validators.ts +15 -0
@@ -19,6 +19,12 @@ export type TaskResult = {
19
19
  * The normalized content returned from the selected provider.
20
20
  */
21
21
  output: Output;
22
+ /**
23
+ * Normalized execution provenance: which target ran, its declared locality, the configured
24
+ * and reported model, and how fallback and routing played out. See
25
+ * execution-provenance.schema.json.
26
+ */
27
+ provenance?: ExecutionProvenance;
22
28
  /**
23
29
  * A unique, opaque identifier assigned by the engine for this specific execution attempt.
24
30
  */
@@ -59,6 +65,108 @@ export type Output = {
59
65
  type: "text";
60
66
  [property: string]: unknown;
61
67
  };
68
+ /**
69
+ * Normalized execution provenance: which target ran, its declared locality, the configured
70
+ * and reported model, and how fallback and routing played out. See
71
+ * execution-provenance.schema.json.
72
+ *
73
+ * Provider-neutral record of how an execution was carried out: the target the outcome is
74
+ * attributed to, its declared locality, the configured and provider-reported model, every
75
+ * attempt, and why other candidates were rejected. Carried on TaskResult, on every
76
+ * StreamTerminalOutcome branch, and on IndeRunError. It reports what the engine observed
77
+ * and what providers declared or reported; it never infers a model or locality a provider
78
+ * did not state, and it never contains request content, credentials, or provider payloads.
79
+ */
80
+ export type ExecutionProvenance = {
81
+ /**
82
+ * How many providers were attempted. 0 when the request failed validation or routing, or
83
+ * was cancelled before any attempt started.
84
+ */
85
+ attemptCount: number;
86
+ /**
87
+ * Every attempted provider, in attempt order, with how its attempt ended.
88
+ */
89
+ attempts: ExecutionProvenanceAttempt[];
90
+ /**
91
+ * The model providerId is bound to, as its descriptor declares it. Absent when the provider
92
+ * cannot name its model or no provider is attributed.
93
+ */
94
+ configuredModel?: string;
95
+ /**
96
+ * Whether more than one provider was attempted (attemptCount > 1).
97
+ */
98
+ fallbackOccurred: boolean;
99
+ /**
100
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
101
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
102
+ * providerId is absent.
103
+ */
104
+ locality: Locality;
105
+ /**
106
+ * The model profile the request routed within; 'auto' when the request named none.
107
+ */
108
+ modelProfile: string;
109
+ /**
110
+ * The target the outcome is attributed to: the provider that produced the result, the
111
+ * provider a stream had committed to when it ended, or the provider that was running when
112
+ * it was cancelled. Absent when no provider was reached or when every attempted provider
113
+ * failed before one was committed to.
114
+ */
115
+ providerId?: string;
116
+ /**
117
+ * The model identifier the provider reported in its own response. Absent means the provider
118
+ * did not report one; it is never inferred from configuration.
119
+ */
120
+ reportedModel?: string;
121
+ /**
122
+ * Providers the route planner rejected before any attempt, with the normalized RoutePlan
123
+ * reason codes. Codes only: no provider-supplied messages.
124
+ */
125
+ routeRejections: ExecutionProvenanceRouteRejection[];
126
+ /**
127
+ * Contract schema version used to interpret this provenance record.
128
+ */
129
+ schemaVersion: "1.0";
130
+ [property: string]: unknown;
131
+ };
132
+ export type ExecutionProvenanceAttempt = {
133
+ /**
134
+ * Normalized error class of a failed attempt.
135
+ */
136
+ errorClass?: ErrorClass;
137
+ /**
138
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
139
+ * 'cancelled'.
140
+ */
141
+ outcome: AttemptOutcome;
142
+ providerId: string;
143
+ [property: string]: unknown;
144
+ };
145
+ /**
146
+ * Normalized error class of a failed attempt.
147
+ *
148
+ * Present only if a provider reports a degraded outcome on an otherwise-successful result;
149
+ * no provider in this codebase currently sets this. Distinct from run() throwing — a thrown
150
+ * IndeRunError never produces a TaskResult at all.
151
+ */
152
+ export type ErrorClass = "CapabilityMismatch" | "Offline" | "AuthError" | "RateLimited" | "Timeout" | "Unavailable" | "Internal";
153
+ /**
154
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
155
+ * 'cancelled'.
156
+ */
157
+ export type AttemptOutcome = "succeeded" | "failed" | "cancelled";
158
+ /**
159
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
160
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
161
+ * providerId is absent.
162
+ */
163
+ export type Locality = "on_device" | "edge" | "cloud" | "unknown";
164
+ export type ExecutionProvenanceRouteRejection = {
165
+ codes: Code[];
166
+ providerId: string;
167
+ [property: string]: unknown;
168
+ };
169
+ export type Code = "task_not_supported" | "run_not_supported" | "streaming_not_supported" | "streaming_unavailable" | "privacy_constraint" | "cloud_constraint" | "offline" | "capability_unavailable" | "not_in_model_profile";
62
170
  /**
63
171
  * Required metadata providing an overview of the execution result and performance metrics.
64
172
  */
@@ -74,6 +182,12 @@ export type Telemetry = {
74
182
  * 'openai_compatible_cloud').
75
183
  */
76
184
  providerUsed: string;
185
+ /**
186
+ * The model identifier the provider reported in its own response, set by the provider when
187
+ * its backend reports one. The engine carries it into provenance.reportedModel; it is never
188
+ * inferred from configuration.
189
+ */
190
+ reportedModel?: string;
77
191
  /**
78
192
  * Measured execution duration in milliseconds, including route selection and result
79
193
  * processing.
@@ -81,12 +195,6 @@ export type Telemetry = {
81
195
  totalMs: number;
82
196
  [property: string]: unknown;
83
197
  };
84
- /**
85
- * Present only if a provider reports a degraded outcome on an otherwise-successful result;
86
- * no provider in this codebase currently sets this. Distinct from run() throwing — a thrown
87
- * IndeRunError never produces a TaskResult at all.
88
- */
89
- export type ErrorClass = "CapabilityMismatch" | "Offline" | "AuthError" | "RateLimited" | "Timeout" | "Unavailable" | "Internal";
90
198
  /**
91
199
  * Optional metadata regarding the quantity of tokens processed by the provider.
92
200
  */
@@ -1 +1 @@
1
- {"version":3,"file":"task-result.d.ts","sourceRoot":"","sources":["../../src/generated/task-result.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB;;;;;;OAMG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,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,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/B,CAAA"}
package/dist/index.d.ts CHANGED
@@ -14,13 +14,13 @@
14
14
  /** The generated request/response, streaming, routing, and telemetry models. */
15
15
  export type * from "./generated/index.js";
16
16
  /** The JSON Schemas those models were generated from, for runtime use. */
17
- export { httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
17
+ export { executionProvenanceSchema, httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
18
18
  /**
19
19
  * Ajv-backed validators for each contract. The `get*ValidationIssues` form returns
20
20
  * a list of human-readable issues (empty when valid); the `validate*` form is the
21
21
  * boolean type guard.
22
22
  */
23
- export { getHttpRequestValidationIssues, getHttpResponseValidationIssues, getIndeRunErrorValidationIssues, getModelPackageValidationIssues, getRoutePlanValidationIssues, getRoutePlannerInputValidationIssues, getStreamEventValidationIssues, getStreamRunHandleValidationIssues, getStreamTerminalOutcomeValidationIssues, getTaskRequestValidationIssues, getTaskResultValidationIssues, getTelemetryEventValidationIssues, validateHttpRequest, validateHttpResponse, validateIndeRunError, validateModelPackage, validateRoutePlan, validateRoutePlannerInput, validateStreamEvent, validateStreamRunHandle, validateStreamTerminalOutcome, validateTaskRequest, validateTaskResult, validateTelemetryEvent, type ValidationIssue } from "./validators.js";
23
+ export { getExecutionProvenanceValidationIssues, getHttpRequestValidationIssues, getHttpResponseValidationIssues, getIndeRunErrorValidationIssues, getModelPackageValidationIssues, getRoutePlanValidationIssues, getRoutePlannerInputValidationIssues, getStreamEventValidationIssues, getStreamRunHandleValidationIssues, getStreamTerminalOutcomeValidationIssues, getTaskRequestValidationIssues, getTaskResultValidationIssues, getTelemetryEventValidationIssues, validateExecutionProvenance, validateHttpRequest, validateHttpResponse, validateIndeRunError, validateModelPackage, validateRoutePlan, validateRoutePlannerInput, validateStreamEvent, validateStreamRunHandle, validateStreamTerminalOutcome, validateTaskRequest, validateTaskResult, validateTelemetryEvent, type ValidationIssue } from "./validators.js";
24
24
  /**
25
25
  * Narrowed aliases over the generated models: the closed enums the SDKs switch on,
26
26
  * and the routing input/output shapes under the names the engines use.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,mBAAmB,sBAAsB,CAAC;AAE1C,0EAA0E;AAC1E,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B;;;;GAIG;AACH,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,oCAAoC,EACpC,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AACzB;;;GAGG;AACH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACb,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,mBAAmB,sBAAsB,CAAC;AAE1C,0EAA0E;AAC1E,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B;;;;GAIG;AACH,OAAO,EACL,sCAAsC,EACtC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,oCAAoC,EACpC,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AACzB;;;GAGG;AACH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACb,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -12,10 +12,10 @@
12
12
  * themselves or the runtime validators.
13
13
  */
14
14
  /** The JSON Schemas those models were generated from, for runtime use. */
15
- export { httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
15
+ export { executionProvenanceSchema, httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
16
16
  /**
17
17
  * Ajv-backed validators for each contract. The `get*ValidationIssues` form returns
18
18
  * a list of human-readable issues (empty when valid); the `validate*` form is the
19
19
  * boolean type guard.
20
20
  */
21
- export { getHttpRequestValidationIssues, getHttpResponseValidationIssues, getIndeRunErrorValidationIssues, getModelPackageValidationIssues, getRoutePlanValidationIssues, getRoutePlannerInputValidationIssues, getStreamEventValidationIssues, getStreamRunHandleValidationIssues, getStreamTerminalOutcomeValidationIssues, getTaskRequestValidationIssues, getTaskResultValidationIssues, getTelemetryEventValidationIssues, validateHttpRequest, validateHttpResponse, validateIndeRunError, validateModelPackage, validateRoutePlan, validateRoutePlannerInput, validateStreamEvent, validateStreamRunHandle, validateStreamTerminalOutcome, validateTaskRequest, validateTaskResult, validateTelemetryEvent } from "./validators.js";
21
+ export { getExecutionProvenanceValidationIssues, getHttpRequestValidationIssues, getHttpResponseValidationIssues, getIndeRunErrorValidationIssues, getModelPackageValidationIssues, getRoutePlanValidationIssues, getRoutePlannerInputValidationIssues, getStreamEventValidationIssues, getStreamRunHandleValidationIssues, getStreamTerminalOutcomeValidationIssues, getTaskRequestValidationIssues, getTaskResultValidationIssues, getTelemetryEventValidationIssues, validateExecutionProvenance, validateHttpRequest, validateHttpResponse, validateIndeRunError, validateModelPackage, validateRoutePlan, validateRoutePlannerInput, validateStreamEvent, validateStreamRunHandle, validateStreamTerminalOutcome, validateTaskRequest, validateTaskResult, validateTelemetryEvent } from "./validators.js";
@@ -1,3 +1,4 @@
1
+ import type { ExecutionProvenance } from "./generated/execution-provenance.js";
1
2
  import type { IndeRunError } from "./generated/inderun-error.js";
2
3
  import type { HttpRequest } from "./generated/http-request.js";
3
4
  import type { HttpResponse } from "./generated/http-response.js";
@@ -30,6 +31,8 @@ export declare function validateStreamTerminalOutcome(value: unknown): value is
30
31
  export declare function getTaskRequestValidationIssues(value: unknown): ValidationIssue[];
31
32
  export declare function getTaskResultValidationIssues(value: unknown): ValidationIssue[];
32
33
  export declare function getIndeRunErrorValidationIssues(value: unknown): ValidationIssue[];
34
+ export declare function validateExecutionProvenance(value: unknown): value is ExecutionProvenance;
35
+ export declare function getExecutionProvenanceValidationIssues(value: unknown): ValidationIssue[];
33
36
  export declare function getHttpRequestValidationIssues(value: unknown): ValidationIssue[];
34
37
  export declare function getHttpResponseValidationIssues(value: unknown): ValidationIssue[];
35
38
  export declare function getTelemetryEventValidationIssues(value: unknown): ValidationIssue[];
@@ -1 +1 @@
1
- {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAA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G,eAAe,EAAE,CAEtF;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAE9E;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAIjF;AAED,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAEpF;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAIhF;AAED,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAI1F"}
@@ -1,5 +1,5 @@
1
1
  import Ajv2020 from "ajv/dist/2020.js";
2
- import { httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
2
+ import { executionProvenanceSchema, httpRequestSchema, httpResponseSchema, inderunErrorSchema, modelPackageSchema, routePlanSchema, routePlannerInputSchema, streamEventSchema, streamRunSchema, streamTerminalOutcomeSchema, taskRequestSchema, taskResultSchema, telemetryEventSchema } from "./generated/index.js";
3
3
  const Ajv2020Constructor = Ajv2020;
4
4
  const ajv = new Ajv2020Constructor({
5
5
  allErrors: true,
@@ -7,6 +7,9 @@ const ajv = new Ajv2020Constructor({
7
7
  strictRequired: false,
8
8
  validateSchema: true
9
9
  });
10
+ // Referenced by `$ref` from every schema that carries provenance, so it has to be known
11
+ // to Ajv before any of them compiles. Compiling it registers it under its `$id`.
12
+ const validateExecutionProvenanceSchema = ajv.compile(executionProvenanceSchema);
10
13
  const validateTaskRequestSchema = ajv.compile(taskRequestSchema);
11
14
  const validateTaskResultSchema = ajv.compile(taskResultSchema);
12
15
  const validateIndeRunErrorSchema = ajv.compile(inderunErrorSchema);
@@ -72,6 +75,14 @@ export function getIndeRunErrorValidationIssues(value) {
72
75
  forbidInlineSecrets: true
73
76
  });
74
77
  }
78
+ export function validateExecutionProvenance(value) {
79
+ return getExecutionProvenanceValidationIssues(value).length === 0;
80
+ }
81
+ export function getExecutionProvenanceValidationIssues(value) {
82
+ return getValidationIssues(validateExecutionProvenanceSchema, value, {
83
+ forbidInlineSecrets: true
84
+ });
85
+ }
75
86
  export function getHttpRequestValidationIssues(value) {
76
87
  return getValidationIssues(validateHttpRequestSchema, value);
77
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@independo/inderun-contracts",
3
- "version": "0.3.3",
3
+ "version": "0.4.0-rc.2",
4
4
  "description": "Canonical JSON Schemas, generated TypeScript types, and validators for the IndeRun task, streaming, error, and routing contracts.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -0,0 +1,102 @@
1
+ /* This file was generated from JSON Schema using quicktype. Do not edit by hand. */
2
+
3
+ /**
4
+ * Provider-neutral record of how an execution was carried out: the target the outcome is
5
+ * attributed to, its declared locality, the configured and provider-reported model, every
6
+ * attempt, and why other candidates were rejected. Carried on TaskResult, on every
7
+ * StreamTerminalOutcome branch, and on IndeRunError. It reports what the engine observed
8
+ * and what providers declared or reported; it never infers a model or locality a provider
9
+ * did not state, and it never contains request content, credentials, or provider payloads.
10
+ */
11
+ export type ExecutionProvenance = {
12
+ /**
13
+ * How many providers were attempted. 0 when the request failed validation or routing, or
14
+ * was cancelled before any attempt started.
15
+ */
16
+ attemptCount: number;
17
+ /**
18
+ * Every attempted provider, in attempt order, with how its attempt ended.
19
+ */
20
+ attempts: ExecutionProvenanceAttempt[];
21
+ /**
22
+ * The model providerId is bound to, as its descriptor declares it. Absent when the provider
23
+ * cannot name its model or no provider is attributed.
24
+ */
25
+ configuredModel?: string;
26
+ /**
27
+ * Whether more than one provider was attempted (attemptCount > 1).
28
+ */
29
+ fallbackOccurred: boolean;
30
+ /**
31
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
32
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
33
+ * providerId is absent.
34
+ */
35
+ locality: Locality;
36
+ /**
37
+ * The model profile the request routed within; 'auto' when the request named none.
38
+ */
39
+ modelProfile: string;
40
+ /**
41
+ * The target the outcome is attributed to: the provider that produced the result, the
42
+ * provider a stream had committed to when it ended, or the provider that was running when
43
+ * it was cancelled. Absent when no provider was reached or when every attempted provider
44
+ * failed before one was committed to.
45
+ */
46
+ providerId?: string;
47
+ /**
48
+ * The model identifier the provider reported in its own response. Absent means the provider
49
+ * did not report one; it is never inferred from configuration.
50
+ */
51
+ reportedModel?: string;
52
+ /**
53
+ * Providers the route planner rejected before any attempt, with the normalized RoutePlan
54
+ * reason codes. Codes only: no provider-supplied messages.
55
+ */
56
+ routeRejections: ExecutionProvenanceRouteRejection[];
57
+ /**
58
+ * Contract schema version used to interpret this provenance record.
59
+ */
60
+ schemaVersion: "1.0";
61
+ [property: string]: unknown;
62
+ }
63
+
64
+ export type ExecutionProvenanceAttempt = {
65
+ /**
66
+ * Normalized error class of a failed attempt.
67
+ */
68
+ errorClass?: ErrorClass;
69
+ /**
70
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
71
+ * 'cancelled'.
72
+ */
73
+ outcome: AttemptOutcome;
74
+ providerId: string;
75
+ [property: string]: unknown;
76
+ }
77
+
78
+ /**
79
+ * Normalized error class of a failed attempt.
80
+ */
81
+ export type ErrorClass = "CapabilityMismatch" | "Offline" | "AuthError" | "RateLimited" | "Timeout" | "Unavailable" | "Internal";
82
+
83
+ /**
84
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
85
+ * 'cancelled'.
86
+ */
87
+ export type AttemptOutcome = "succeeded" | "failed" | "cancelled";
88
+
89
+ /**
90
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
91
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
92
+ * providerId is absent.
93
+ */
94
+ export type Locality = "on_device" | "edge" | "cloud" | "unknown";
95
+
96
+ export type ExecutionProvenanceRouteRejection = {
97
+ codes: Code[];
98
+ providerId: string;
99
+ [property: string]: unknown;
100
+ }
101
+
102
+ export type Code = "task_not_supported" | "run_not_supported" | "streaming_not_supported" | "streaming_unavailable" | "privacy_constraint" | "cloud_constraint" | "offline" | "capability_unavailable" | "not_in_model_profile";
@@ -22,6 +22,12 @@ export type IndeRunError = {
22
22
  * Human-readable error message suitable for logs and developer diagnostics.
23
23
  */
24
24
  message: string;
25
+ /**
26
+ * Normalized execution provenance: which target ran, its declared locality, the configured
27
+ * and reported model, and how fallback and routing played out. See
28
+ * execution-provenance.schema.json.
29
+ */
30
+ provenance?: ExecutionProvenance;
25
31
  /**
26
32
  * Identifier of the provider associated with the failure, if execution reached a provider.
27
33
  */
@@ -51,5 +57,107 @@ export type IndeRunError = {
51
57
  * Offline/Unavailable (provider unreachable or not ready), AuthError (credential/auth
52
58
  * failure), RateLimited (provider throttled the request), Timeout (provider exceeded its
53
59
  * execution budget), Internal (unexpected engine-side failure).
60
+ *
61
+ * Normalized error class of a failed attempt.
54
62
  */
55
63
  export type ErrorClass = "CapabilityMismatch" | "Offline" | "AuthError" | "RateLimited" | "Timeout" | "Unavailable" | "Internal";
64
+
65
+ /**
66
+ * Normalized execution provenance: which target ran, its declared locality, the configured
67
+ * and reported model, and how fallback and routing played out. See
68
+ * execution-provenance.schema.json.
69
+ *
70
+ * Provider-neutral record of how an execution was carried out: the target the outcome is
71
+ * attributed to, its declared locality, the configured and provider-reported model, every
72
+ * attempt, and why other candidates were rejected. Carried on TaskResult, on every
73
+ * StreamTerminalOutcome branch, and on IndeRunError. It reports what the engine observed
74
+ * and what providers declared or reported; it never infers a model or locality a provider
75
+ * did not state, and it never contains request content, credentials, or provider payloads.
76
+ */
77
+ export type ExecutionProvenance = {
78
+ /**
79
+ * How many providers were attempted. 0 when the request failed validation or routing, or
80
+ * was cancelled before any attempt started.
81
+ */
82
+ attemptCount: number;
83
+ /**
84
+ * Every attempted provider, in attempt order, with how its attempt ended.
85
+ */
86
+ attempts: ExecutionProvenanceAttempt[];
87
+ /**
88
+ * The model providerId is bound to, as its descriptor declares it. Absent when the provider
89
+ * cannot name its model or no provider is attributed.
90
+ */
91
+ configuredModel?: string;
92
+ /**
93
+ * Whether more than one provider was attempted (attemptCount > 1).
94
+ */
95
+ fallbackOccurred: boolean;
96
+ /**
97
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
98
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
99
+ * providerId is absent.
100
+ */
101
+ locality: Locality;
102
+ /**
103
+ * The model profile the request routed within; 'auto' when the request named none.
104
+ */
105
+ modelProfile: string;
106
+ /**
107
+ * The target the outcome is attributed to: the provider that produced the result, the
108
+ * provider a stream had committed to when it ended, or the provider that was running when
109
+ * it was cancelled. Absent when no provider was reached or when every attempted provider
110
+ * failed before one was committed to.
111
+ */
112
+ providerId?: string;
113
+ /**
114
+ * The model identifier the provider reported in its own response. Absent means the provider
115
+ * did not report one; it is never inferred from configuration.
116
+ */
117
+ reportedModel?: string;
118
+ /**
119
+ * Providers the route planner rejected before any attempt, with the normalized RoutePlan
120
+ * reason codes. Codes only: no provider-supplied messages.
121
+ */
122
+ routeRejections: ExecutionProvenanceRouteRejection[];
123
+ /**
124
+ * Contract schema version used to interpret this provenance record.
125
+ */
126
+ schemaVersion: "1.0";
127
+ [property: string]: unknown;
128
+ }
129
+
130
+ export type ExecutionProvenanceAttempt = {
131
+ /**
132
+ * Normalized error class of a failed attempt.
133
+ */
134
+ errorClass?: ErrorClass;
135
+ /**
136
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
137
+ * 'cancelled'.
138
+ */
139
+ outcome: AttemptOutcome;
140
+ providerId: string;
141
+ [property: string]: unknown;
142
+ }
143
+
144
+ /**
145
+ * 'succeeded' (produced the result or was committed to and completed), 'failed', or
146
+ * 'cancelled'.
147
+ */
148
+ export type AttemptOutcome = "succeeded" | "failed" | "cancelled";
149
+
150
+ /**
151
+ * Where providerId declares it executes: 'on_device' for a local provider, 'edge', or
152
+ * 'cloud'. A declaration by the provider's descriptor, not a measurement. 'unknown' when
153
+ * providerId is absent.
154
+ */
155
+ export type Locality = "on_device" | "edge" | "cloud" | "unknown";
156
+
157
+ export type ExecutionProvenanceRouteRejection = {
158
+ codes: Code[];
159
+ providerId: string;
160
+ [property: string]: unknown;
161
+ }
162
+
163
+ export type Code = "task_not_supported" | "run_not_supported" | "streaming_not_supported" | "streaming_unavailable" | "privacy_constraint" | "cloud_constraint" | "offline" | "capability_unavailable" | "not_in_model_profile";
@@ -12,4 +12,5 @@ export type { ModelPackage } from "./model-package.js";
12
12
  export type { StreamRunHandle } from "./stream-run.js";
13
13
  export type { StreamEvent } from "./stream-event.js";
14
14
  export type { StreamTerminalOutcome } from "./stream-terminal-outcome.js";
15
+ export type { ExecutionProvenance } from "./execution-provenance.js";
15
16
  export * from "./schemas.js";
@@ -62,7 +62,8 @@ export type Reason = {
62
62
  * Normalized rejection reason. 'streaming_not_supported' means the descriptor does not
63
63
  * statically declare Mode-2 streaming; 'streaming_unavailable' means it declares streaming
64
64
  * but the dynamic capability snapshot reports it cannot stream in the current host
65
- * environment.
65
+ * environment. 'not_in_model_profile' means the request named a model profile that does not
66
+ * list this provider.
66
67
  */
67
68
  code: Code;
68
69
  message: string;
@@ -73,6 +74,7 @@ export type Reason = {
73
74
  * Normalized rejection reason. 'streaming_not_supported' means the descriptor does not
74
75
  * statically declare Mode-2 streaming; 'streaming_unavailable' means it declares streaming
75
76
  * but the dynamic capability snapshot reports it cannot stream in the current host
76
- * environment.
77
+ * environment. 'not_in_model_profile' means the request named a model profile that does not
78
+ * list this provider.
77
79
  */
78
- export type Code = "task_not_supported" | "run_not_supported" | "streaming_not_supported" | "streaming_unavailable" | "privacy_constraint" | "cloud_constraint" | "offline" | "capability_unavailable";
80
+ export type Code = "task_not_supported" | "run_not_supported" | "streaming_not_supported" | "streaming_unavailable" | "privacy_constraint" | "cloud_constraint" | "offline" | "capability_unavailable" | "not_in_model_profile";
@@ -14,6 +14,14 @@ export type RoutePlannerInput = {
14
14
  * eligible providers; it never changes candidate ordering.
15
15
  */
16
16
  interactionMode?: InteractionMode;
17
+ /**
18
+ * The resolved model profile the request routes within. Absent means the built-in 'auto'
19
+ * profile: no allow-list, and ordering by placement and preference alone. When present,
20
+ * providers whose id is not in targetIds are rejected with 'not_in_model_profile', and the
21
+ * position in targetIds ranks the survivors after placement and before preferences. Ids
22
+ * that name no registered provider are ignored.
23
+ */
24
+ modelProfile?: ModelProfile;
17
25
  /**
18
26
  * Soft route ordering preferences applied after hard filtering.
19
27
  */
@@ -65,6 +73,25 @@ export type PrivacyEnum = "local_required" | "local_preferred" | "cloud_allowed"
65
73
  */
66
74
  export type InteractionMode = "run" | "stream";
67
75
 
76
+ /**
77
+ * The resolved model profile the request routes within. Absent means the built-in 'auto'
78
+ * profile: no allow-list, and ordering by placement and preference alone. When present,
79
+ * providers whose id is not in targetIds are rejected with 'not_in_model_profile', and the
80
+ * position in targetIds ranks the survivors after placement and before preferences. Ids
81
+ * that name no registered provider are ignored.
82
+ */
83
+ export type ModelProfile = {
84
+ /**
85
+ * Profile name, carried for explanations.
86
+ */
87
+ name: string;
88
+ /**
89
+ * Provider ids in profile order.
90
+ */
91
+ targetIds: [string, ...string[]];
92
+ [property: string]: unknown;
93
+ }
94
+
68
95
  /**
69
96
  * Soft route ordering preferences applied after hard filtering.
70
97
  */