iterate-kernel 0.1.4 → 0.1.5
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/README.md +14 -6
- package/dist/convergence.d.ts +90 -0
- package/dist/convergence.d.ts.map +1 -0
- package/dist/convergence.js +97 -0
- package/dist/convergence.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -1
- package/dist/evidence-pack.d.ts +19 -19
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/invariant-report.d.ts +271 -0
- package/dist/invariant-report.d.ts.map +1 -0
- package/dist/invariant-report.js +145 -0
- package/dist/invariant-report.js.map +1 -0
- package/dist/parse.d.ts +7 -0
- package/dist/parse.d.ts.map +1 -1
- package/dist/parse.js +18 -10
- package/dist/parse.js.map +1 -1
- package/dist/provider-registration.d.ts +132 -0
- package/dist/provider-registration.d.ts.map +1 -0
- package/dist/provider-registration.js +119 -0
- package/dist/provider-registration.js.map +1 -0
- package/dist/schemas.d.ts +8 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +8 -0
- package/dist/schemas.js.map +1 -1
- package/fixtures/convergence.ok-01.json +252 -0
- package/fixtures/invariant-report.ok-01.json +306 -0
- package/fixtures/provider-registration.ok-01.json +309 -0
- package/fixtures/run-plan.ok-01.json +1 -1
- package/package.json +13 -1
- package/schemas/convergence-round-state.schema.json +37 -0
- package/schemas/invariant-report.schema.json +108 -0
- package/schemas/provider-registration.schema.json +63 -0
- package/schemas/reverification-request.schema.json +89 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type RecipeStep } from "./recipe-config.js";
|
|
3
|
+
/**
|
|
4
|
+
* The invariant report and the re-verification it can trigger (5.7 R40 scenario 1).
|
|
5
|
+
*
|
|
6
|
+
* Why a contract instead of a function call: iterate-harness runs the invariants
|
|
7
|
+
* (its defensive kernel owns `ensure` assertions and command lists), and GlassPane
|
|
8
|
+
* owns the only thing that can re-verify a GUI claim — the engine. Neither may
|
|
9
|
+
* reach into the other, so the failure has to become a value both sides can name,
|
|
10
|
+
* hash, and put in a ledger.
|
|
11
|
+
*
|
|
12
|
+
* The kernel orchestrates; it never judges. Nothing here decides whether an
|
|
13
|
+
* invariant holds — it validates what the runner reported and refuses a report that
|
|
14
|
+
* contradicts itself. That refusal is the point: a pass labelled over a failed
|
|
15
|
+
* check is exactly how a loop reports convergence it did not earn.
|
|
16
|
+
*/
|
|
17
|
+
export declare const INVARIANT_REPORT_SCHEMA_VERSION: "iterate.invariant-report/0.1";
|
|
18
|
+
export declare const REVERIFICATION_SCHEMA_VERSION: "iterate.reverification/0.1";
|
|
19
|
+
export declare const INVARIANT_CHECK_MAX = 256;
|
|
20
|
+
export declare const INVARIANT_DETAIL_MAX_LENGTH = 4096;
|
|
21
|
+
/**
|
|
22
|
+
* The three states the invariant runner actually emits.
|
|
23
|
+
*
|
|
24
|
+
* `refused` is not a judgement about the project: it is the runner declining to
|
|
25
|
+
* execute a configured command because the command string carries shell-chaining
|
|
26
|
+
* metacharacters or is empty. It is a check outcome rather than a report outcome
|
|
27
|
+
* because the runner treats it as a violation and rolls the edit back — a report
|
|
28
|
+
* whose only failing check was refused is therefore `fail`, not `error`. Collapsing
|
|
29
|
+
* it into `error` would let a polluted config look like an unmeasured run.
|
|
30
|
+
*/
|
|
31
|
+
export declare const InvariantCheckKindSchema: z.ZodEnum<["ensure", "command", "refused"]>;
|
|
32
|
+
export type InvariantCheckKind = z.infer<typeof InvariantCheckKindSchema>;
|
|
33
|
+
export declare const InvariantCheckSchema: z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
kind: z.ZodEnum<["ensure", "command", "refused"]>;
|
|
36
|
+
ok: z.ZodBoolean;
|
|
37
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strict", z.ZodTypeAny, {
|
|
39
|
+
kind: "ensure" | "command" | "refused";
|
|
40
|
+
name: string;
|
|
41
|
+
ok: boolean;
|
|
42
|
+
detail?: string | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
kind: "ensure" | "command" | "refused";
|
|
45
|
+
name: string;
|
|
46
|
+
ok: boolean;
|
|
47
|
+
detail?: string | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
export type InvariantCheck = z.infer<typeof InvariantCheckSchema>;
|
|
50
|
+
export declare const InvariantReportOutcomeSchema: z.ZodEnum<["pass", "fail", "error"]>;
|
|
51
|
+
export type InvariantReportOutcome = z.infer<typeof InvariantReportOutcomeSchema>;
|
|
52
|
+
export declare const InvariantReportSchema: z.ZodEffects<z.ZodObject<{
|
|
53
|
+
schemaVersion: z.ZodLiteral<"iterate.invariant-report/0.1">;
|
|
54
|
+
outcome: z.ZodEnum<["pass", "fail", "error"]>;
|
|
55
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
56
|
+
name: z.ZodString;
|
|
57
|
+
kind: z.ZodEnum<["ensure", "command", "refused"]>;
|
|
58
|
+
ok: z.ZodBoolean;
|
|
59
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, "strict", z.ZodTypeAny, {
|
|
61
|
+
kind: "ensure" | "command" | "refused";
|
|
62
|
+
name: string;
|
|
63
|
+
ok: boolean;
|
|
64
|
+
detail?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
kind: "ensure" | "command" | "refused";
|
|
67
|
+
name: string;
|
|
68
|
+
ok: boolean;
|
|
69
|
+
detail?: string | undefined;
|
|
70
|
+
}>, "many">;
|
|
71
|
+
round: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, "strict", z.ZodTypeAny, {
|
|
74
|
+
schemaVersion: "iterate.invariant-report/0.1";
|
|
75
|
+
outcome: "pass" | "fail" | "error";
|
|
76
|
+
checks: {
|
|
77
|
+
kind: "ensure" | "command" | "refused";
|
|
78
|
+
name: string;
|
|
79
|
+
ok: boolean;
|
|
80
|
+
detail?: string | undefined;
|
|
81
|
+
}[];
|
|
82
|
+
round?: number | undefined;
|
|
83
|
+
durationMs?: number | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
schemaVersion: "iterate.invariant-report/0.1";
|
|
86
|
+
outcome: "pass" | "fail" | "error";
|
|
87
|
+
checks: {
|
|
88
|
+
kind: "ensure" | "command" | "refused";
|
|
89
|
+
name: string;
|
|
90
|
+
ok: boolean;
|
|
91
|
+
detail?: string | undefined;
|
|
92
|
+
}[];
|
|
93
|
+
round?: number | undefined;
|
|
94
|
+
durationMs?: number | undefined;
|
|
95
|
+
}>, {
|
|
96
|
+
schemaVersion: "iterate.invariant-report/0.1";
|
|
97
|
+
outcome: "pass" | "fail" | "error";
|
|
98
|
+
checks: {
|
|
99
|
+
kind: "ensure" | "command" | "refused";
|
|
100
|
+
name: string;
|
|
101
|
+
ok: boolean;
|
|
102
|
+
detail?: string | undefined;
|
|
103
|
+
}[];
|
|
104
|
+
round?: number | undefined;
|
|
105
|
+
durationMs?: number | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
schemaVersion: "iterate.invariant-report/0.1";
|
|
108
|
+
outcome: "pass" | "fail" | "error";
|
|
109
|
+
checks: {
|
|
110
|
+
kind: "ensure" | "command" | "refused";
|
|
111
|
+
name: string;
|
|
112
|
+
ok: boolean;
|
|
113
|
+
detail?: string | undefined;
|
|
114
|
+
}[];
|
|
115
|
+
round?: number | undefined;
|
|
116
|
+
durationMs?: number | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
export type InvariantReport = z.infer<typeof InvariantReportSchema>;
|
|
119
|
+
/** `iv_` + sha256 over the canonical form, so a re-verification can cite the failure. */
|
|
120
|
+
export declare function invariantReportDigest(report: InvariantReport): string;
|
|
121
|
+
export declare function failingChecks(report: InvariantReport): string[];
|
|
122
|
+
export declare const ReverificationTargetsSchema: z.ZodEffects<z.ZodObject<{
|
|
123
|
+
recipeSteps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
124
|
+
kind: z.ZodEnum<["act", "observe", "assert", "diagnose"]>;
|
|
125
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
126
|
+
}, "strict", z.ZodTypeAny, {
|
|
127
|
+
params: Record<string, unknown>;
|
|
128
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
129
|
+
}, {
|
|
130
|
+
params: Record<string, unknown>;
|
|
131
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
132
|
+
}>, "many">>;
|
|
133
|
+
dimensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
134
|
+
operationIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
135
|
+
}, "strict", z.ZodTypeAny, {
|
|
136
|
+
operationIds?: string[] | undefined;
|
|
137
|
+
dimensions?: string[] | undefined;
|
|
138
|
+
recipeSteps?: {
|
|
139
|
+
params: Record<string, unknown>;
|
|
140
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
141
|
+
}[] | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
operationIds?: string[] | undefined;
|
|
144
|
+
dimensions?: string[] | undefined;
|
|
145
|
+
recipeSteps?: {
|
|
146
|
+
params: Record<string, unknown>;
|
|
147
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
}>, {
|
|
150
|
+
operationIds?: string[] | undefined;
|
|
151
|
+
dimensions?: string[] | undefined;
|
|
152
|
+
recipeSteps?: {
|
|
153
|
+
params: Record<string, unknown>;
|
|
154
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
155
|
+
}[] | undefined;
|
|
156
|
+
}, {
|
|
157
|
+
operationIds?: string[] | undefined;
|
|
158
|
+
dimensions?: string[] | undefined;
|
|
159
|
+
recipeSteps?: {
|
|
160
|
+
params: Record<string, unknown>;
|
|
161
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
162
|
+
}[] | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
export type ReverificationTargets = z.infer<typeof ReverificationTargetsSchema>;
|
|
165
|
+
export declare const ReverificationRequestSchema: z.ZodObject<{
|
|
166
|
+
schemaVersion: z.ZodLiteral<"iterate.reverification/0.1">;
|
|
167
|
+
trigger: z.ZodObject<{
|
|
168
|
+
kind: z.ZodLiteral<"invariant">;
|
|
169
|
+
reportDigest: z.ZodString;
|
|
170
|
+
}, "strict", z.ZodTypeAny, {
|
|
171
|
+
kind: "invariant";
|
|
172
|
+
reportDigest: string;
|
|
173
|
+
}, {
|
|
174
|
+
kind: "invariant";
|
|
175
|
+
reportDigest: string;
|
|
176
|
+
}>;
|
|
177
|
+
targets: z.ZodEffects<z.ZodObject<{
|
|
178
|
+
recipeSteps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
179
|
+
kind: z.ZodEnum<["act", "observe", "assert", "diagnose"]>;
|
|
180
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
181
|
+
}, "strict", z.ZodTypeAny, {
|
|
182
|
+
params: Record<string, unknown>;
|
|
183
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
184
|
+
}, {
|
|
185
|
+
params: Record<string, unknown>;
|
|
186
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
187
|
+
}>, "many">>;
|
|
188
|
+
dimensions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
189
|
+
operationIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
190
|
+
}, "strict", z.ZodTypeAny, {
|
|
191
|
+
operationIds?: string[] | undefined;
|
|
192
|
+
dimensions?: string[] | undefined;
|
|
193
|
+
recipeSteps?: {
|
|
194
|
+
params: Record<string, unknown>;
|
|
195
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
196
|
+
}[] | undefined;
|
|
197
|
+
}, {
|
|
198
|
+
operationIds?: string[] | undefined;
|
|
199
|
+
dimensions?: string[] | undefined;
|
|
200
|
+
recipeSteps?: {
|
|
201
|
+
params: Record<string, unknown>;
|
|
202
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
203
|
+
}[] | undefined;
|
|
204
|
+
}>, {
|
|
205
|
+
operationIds?: string[] | undefined;
|
|
206
|
+
dimensions?: string[] | undefined;
|
|
207
|
+
recipeSteps?: {
|
|
208
|
+
params: Record<string, unknown>;
|
|
209
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
210
|
+
}[] | undefined;
|
|
211
|
+
}, {
|
|
212
|
+
operationIds?: string[] | undefined;
|
|
213
|
+
dimensions?: string[] | undefined;
|
|
214
|
+
recipeSteps?: {
|
|
215
|
+
params: Record<string, unknown>;
|
|
216
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
217
|
+
}[] | undefined;
|
|
218
|
+
}>;
|
|
219
|
+
}, "strict", z.ZodTypeAny, {
|
|
220
|
+
schemaVersion: "iterate.reverification/0.1";
|
|
221
|
+
trigger: {
|
|
222
|
+
kind: "invariant";
|
|
223
|
+
reportDigest: string;
|
|
224
|
+
};
|
|
225
|
+
targets: {
|
|
226
|
+
operationIds?: string[] | undefined;
|
|
227
|
+
dimensions?: string[] | undefined;
|
|
228
|
+
recipeSteps?: {
|
|
229
|
+
params: Record<string, unknown>;
|
|
230
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
231
|
+
}[] | undefined;
|
|
232
|
+
};
|
|
233
|
+
}, {
|
|
234
|
+
schemaVersion: "iterate.reverification/0.1";
|
|
235
|
+
trigger: {
|
|
236
|
+
kind: "invariant";
|
|
237
|
+
reportDigest: string;
|
|
238
|
+
};
|
|
239
|
+
targets: {
|
|
240
|
+
operationIds?: string[] | undefined;
|
|
241
|
+
dimensions?: string[] | undefined;
|
|
242
|
+
recipeSteps?: {
|
|
243
|
+
params: Record<string, unknown>;
|
|
244
|
+
kind: "act" | "observe" | "assert" | "diagnose";
|
|
245
|
+
}[] | undefined;
|
|
246
|
+
};
|
|
247
|
+
}>;
|
|
248
|
+
export type ReverificationRequest = z.infer<typeof ReverificationRequestSchema>;
|
|
249
|
+
export declare const REVERIFICATION_CODES: {
|
|
250
|
+
readonly nothingToReverify: "KERNEL_E_REVERIFY_NOT_TRIGGERED";
|
|
251
|
+
readonly unmeasured: "KERNEL_E_REVERIFY_UNMEASURED";
|
|
252
|
+
};
|
|
253
|
+
export type KernelReverificationCode = (typeof REVERIFICATION_CODES)[keyof typeof REVERIFICATION_CODES];
|
|
254
|
+
export declare class KernelReverificationError extends Error {
|
|
255
|
+
readonly code: KernelReverificationCode;
|
|
256
|
+
readonly remedy: string;
|
|
257
|
+
constructor(code: KernelReverificationCode, message: string, remedy: string);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Turn an invariant report into a request, or say why there is none.
|
|
261
|
+
*
|
|
262
|
+
* A passing report produces **no** request — creating an empty one would let a
|
|
263
|
+
* caller log "re-verification scheduled" when nothing failed. An `error` report
|
|
264
|
+
* produces no request either: a check that could not run is not a finding, and
|
|
265
|
+
* spinning up the engine to "re-verify" it would launder an unmeasured state into
|
|
266
|
+
* activity. Both cases carry a remedy so the caller can act without reading this.
|
|
267
|
+
*/
|
|
268
|
+
export declare function reVerificationRequestFrom(report: InvariantReport, targets: ReverificationTargets): ReverificationRequest | null;
|
|
269
|
+
/** Only for callers that hold live steps; declared so the recipe type is not re-invented. */
|
|
270
|
+
export type ReverificationRecipeStep = RecipeStep;
|
|
271
|
+
//# sourceMappingURL=invariant-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant-report.d.ts","sourceRoot":"","sources":["../src/invariant-report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGvE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,+B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AAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAExG,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,GAAG,IAAI,CAoB9B;AAED,6FAA6F;AAC7F,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
4
|
+
import { DIMENSION_ID_MAX_LENGTH, DIMENSION_ID_PATTERN } from "./dimension-context.js";
|
|
5
|
+
import { schemaErrorFrom } from "./errors.js";
|
|
6
|
+
import { RecipeStepSchema } from "./recipe-config.js";
|
|
7
|
+
import { OPERATION_ID_PATTERN } from "./evidence-pack.js";
|
|
8
|
+
/**
|
|
9
|
+
* The invariant report and the re-verification it can trigger (5.7 R40 scenario 1).
|
|
10
|
+
*
|
|
11
|
+
* Why a contract instead of a function call: iterate-harness runs the invariants
|
|
12
|
+
* (its defensive kernel owns `ensure` assertions and command lists), and GlassPane
|
|
13
|
+
* owns the only thing that can re-verify a GUI claim — the engine. Neither may
|
|
14
|
+
* reach into the other, so the failure has to become a value both sides can name,
|
|
15
|
+
* hash, and put in a ledger.
|
|
16
|
+
*
|
|
17
|
+
* The kernel orchestrates; it never judges. Nothing here decides whether an
|
|
18
|
+
* invariant holds — it validates what the runner reported and refuses a report that
|
|
19
|
+
* contradicts itself. That refusal is the point: a pass labelled over a failed
|
|
20
|
+
* check is exactly how a loop reports convergence it did not earn.
|
|
21
|
+
*/
|
|
22
|
+
export const INVARIANT_REPORT_SCHEMA_VERSION = "iterate.invariant-report/0.1";
|
|
23
|
+
export const REVERIFICATION_SCHEMA_VERSION = "iterate.reverification/0.1";
|
|
24
|
+
export const INVARIANT_CHECK_MAX = 256;
|
|
25
|
+
export const INVARIANT_DETAIL_MAX_LENGTH = 4096;
|
|
26
|
+
/**
|
|
27
|
+
* The three states the invariant runner actually emits.
|
|
28
|
+
*
|
|
29
|
+
* `refused` is not a judgement about the project: it is the runner declining to
|
|
30
|
+
* execute a configured command because the command string carries shell-chaining
|
|
31
|
+
* metacharacters or is empty. It is a check outcome rather than a report outcome
|
|
32
|
+
* because the runner treats it as a violation and rolls the edit back — a report
|
|
33
|
+
* whose only failing check was refused is therefore `fail`, not `error`. Collapsing
|
|
34
|
+
* it into `error` would let a polluted config look like an unmeasured run.
|
|
35
|
+
*/
|
|
36
|
+
export const InvariantCheckKindSchema = z.enum(["ensure", "command", "refused"]);
|
|
37
|
+
export const InvariantCheckSchema = z.strictObject({
|
|
38
|
+
name: z.string().min(1).max(256),
|
|
39
|
+
kind: InvariantCheckKindSchema,
|
|
40
|
+
ok: z.boolean(),
|
|
41
|
+
// Absent means "the runner said nothing about it" — never a synthesised "ok".
|
|
42
|
+
detail: z.string().max(INVARIANT_DETAIL_MAX_LENGTH).optional()
|
|
43
|
+
});
|
|
44
|
+
export const InvariantReportOutcomeSchema = z.enum(["pass", "fail", "error"]);
|
|
45
|
+
export const InvariantReportSchema = z
|
|
46
|
+
.strictObject({
|
|
47
|
+
schemaVersion: z.literal(INVARIANT_REPORT_SCHEMA_VERSION),
|
|
48
|
+
outcome: InvariantReportOutcomeSchema,
|
|
49
|
+
checks: z.array(InvariantCheckSchema).min(1).max(INVARIANT_CHECK_MAX),
|
|
50
|
+
round: z.number().int().min(1).optional(),
|
|
51
|
+
durationMs: z.number().int().min(0).optional()
|
|
52
|
+
})
|
|
53
|
+
.superRefine((report, ctx) => {
|
|
54
|
+
const failed = report.checks.filter((check) => !check.ok).map((check) => check.name);
|
|
55
|
+
if (report.outcome === "pass" && failed.length > 0) {
|
|
56
|
+
// The one contradiction a report must never be allowed to carry.
|
|
57
|
+
ctx.addIssue({
|
|
58
|
+
code: z.ZodIssueCode.custom,
|
|
59
|
+
path: ["outcome"],
|
|
60
|
+
message: `outcome is "pass" but ${failed.length} check(s) did not pass: ${failed.join(", ")}`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (report.outcome === "fail" && failed.length === 0) {
|
|
64
|
+
ctx.addIssue({
|
|
65
|
+
code: z.ZodIssueCode.custom,
|
|
66
|
+
path: ["outcome"],
|
|
67
|
+
message: 'outcome is "fail" but every check reports ok; a failing report must name what failed'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
/** `iv_` + sha256 over the canonical form, so a re-verification can cite the failure. */
|
|
72
|
+
export function invariantReportDigest(report) {
|
|
73
|
+
return `iv_${createHash("sha256").update(canonicalJson(report)).digest("hex")}`;
|
|
74
|
+
}
|
|
75
|
+
export function failingChecks(report) {
|
|
76
|
+
return report.checks.filter((check) => !check.ok).map((check) => check.name);
|
|
77
|
+
}
|
|
78
|
+
export const ReverificationTargetsSchema = z
|
|
79
|
+
.strictObject({
|
|
80
|
+
recipeSteps: z.array(RecipeStepSchema).min(1).max(64).optional(),
|
|
81
|
+
dimensions: z
|
|
82
|
+
.array(z.string().regex(DIMENSION_ID_PATTERN).max(DIMENSION_ID_MAX_LENGTH))
|
|
83
|
+
.min(1)
|
|
84
|
+
.max(64)
|
|
85
|
+
.optional(),
|
|
86
|
+
operationIds: z.array(z.string().regex(OPERATION_ID_PATTERN)).min(1).max(64).optional()
|
|
87
|
+
})
|
|
88
|
+
.superRefine((targets, ctx) => {
|
|
89
|
+
if (!targets.recipeSteps && !targets.dimensions && !targets.operationIds) {
|
|
90
|
+
ctx.addIssue({
|
|
91
|
+
code: z.ZodIssueCode.custom,
|
|
92
|
+
path: [],
|
|
93
|
+
message: "an empty target set is not a re-verification: state which recipe steps, dimensions, or operations to re-run"
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
export const ReverificationRequestSchema = z.strictObject({
|
|
98
|
+
schemaVersion: z.literal(REVERIFICATION_SCHEMA_VERSION),
|
|
99
|
+
trigger: z.strictObject({
|
|
100
|
+
kind: z.literal("invariant"),
|
|
101
|
+
reportDigest: z.string().regex(/^iv_[0-9a-f]{64}$/)
|
|
102
|
+
}),
|
|
103
|
+
targets: ReverificationTargetsSchema
|
|
104
|
+
});
|
|
105
|
+
export const REVERIFICATION_CODES = {
|
|
106
|
+
nothingToReverify: "KERNEL_E_REVERIFY_NOT_TRIGGERED",
|
|
107
|
+
unmeasured: "KERNEL_E_REVERIFY_UNMEASURED"
|
|
108
|
+
};
|
|
109
|
+
export class KernelReverificationError extends Error {
|
|
110
|
+
code;
|
|
111
|
+
remedy;
|
|
112
|
+
constructor(code, message, remedy) {
|
|
113
|
+
super(`${code}: ${message}`);
|
|
114
|
+
this.name = "KernelReverificationError";
|
|
115
|
+
this.code = code;
|
|
116
|
+
this.remedy = remedy;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Turn an invariant report into a request, or say why there is none.
|
|
121
|
+
*
|
|
122
|
+
* A passing report produces **no** request — creating an empty one would let a
|
|
123
|
+
* caller log "re-verification scheduled" when nothing failed. An `error` report
|
|
124
|
+
* produces no request either: a check that could not run is not a finding, and
|
|
125
|
+
* spinning up the engine to "re-verify" it would launder an unmeasured state into
|
|
126
|
+
* activity. Both cases carry a remedy so the caller can act without reading this.
|
|
127
|
+
*/
|
|
128
|
+
export function reVerificationRequestFrom(report, targets) {
|
|
129
|
+
if (report.outcome === "pass") {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
if (report.outcome === "error") {
|
|
133
|
+
throw new KernelReverificationError(REVERIFICATION_CODES.unmeasured, "the invariant run reported error, not a verdict", "fix or re-run the invariant check itself; a re-verification of the app would answer a question nobody measured");
|
|
134
|
+
}
|
|
135
|
+
const checked = ReverificationTargetsSchema.safeParse(targets);
|
|
136
|
+
if (!checked.success) {
|
|
137
|
+
throw schemaErrorFrom("re-verification targets", checked.error);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
schemaVersion: REVERIFICATION_SCHEMA_VERSION,
|
|
141
|
+
trigger: { kind: "invariant", reportDigest: invariantReportDigest(report) },
|
|
142
|
+
targets: checked.data
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=invariant-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant-report.js","sourceRoot":"","sources":["../src/invariant-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAmB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,8BAAuC,CAAC;AACvF,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAAqC,CAAC;AAEnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;A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ecisionLogEntry } from "./decision-log-entry.js";
|
|
|
3
3
|
import { type DimensionContext, type DimensionContextInput } from "./dimension-context.js";
|
|
4
4
|
import { type RecipeConfig } from "./recipe-config.js";
|
|
5
5
|
import { type RunPlan } from "./run-plan.js";
|
|
6
|
+
import { type InvariantReport, type ReverificationRequest } from "./invariant-report.js";
|
|
7
|
+
import { type RoundState } from "./convergence.js";
|
|
8
|
+
import { type ProviderRegistration } from "./provider-registration.js";
|
|
6
9
|
export declare function parseEvidencePack(input: unknown): EvidencePack;
|
|
7
10
|
/**
|
|
8
11
|
* Reads an evidence pack produced by the engine, tolerating only the two
|
|
@@ -21,4 +24,8 @@ export declare function parseRecipeConfig(input: unknown): RecipeConfig;
|
|
|
21
24
|
export declare function parseRunPlan(input: unknown): RunPlan;
|
|
22
25
|
export declare function parseDimensionContext(input: unknown): DimensionContext;
|
|
23
26
|
export declare function parseDimensionContextInput(input: unknown): DimensionContextInput;
|
|
27
|
+
export declare function parseInvariantReport(input: unknown): InvariantReport;
|
|
28
|
+
export declare function parseReverificationRequest(input: unknown): ReverificationRequest;
|
|
29
|
+
export declare function parseRoundState(input: unknown): RoundState;
|
|
30
|
+
export declare function parseProviderRegistration(input: unknown): ProviderRegistration;
|
|
24
31
|
//# sourceMappingURL=parse.d.ts.map
|
package/dist/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC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AK,EAAE,OAAO,GAAG,UAAU,CAE1D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAE9E"}
|
package/dist/parse.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { schemaErrorFrom } from "./errors.js";
|
|
2
2
|
import { EvidencePackReadSchema, EvidencePackSchema } from "./evidence-pack.js";
|
|
3
3
|
import { DecisionLogEntrySchema } from "./decision-log-entry.js";
|
|
4
4
|
import { DimensionContextInputSchema, DimensionContextSchema } from "./dimension-context.js";
|
|
5
5
|
import { RecipeConfigSchema } from "./recipe-config.js";
|
|
6
6
|
import { RunPlanSchema } from "./run-plan.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
message: issue.message
|
|
11
|
-
}));
|
|
12
|
-
return new KernelSchemaError(label, issues);
|
|
13
|
-
}
|
|
7
|
+
import { InvariantReportSchema, ReverificationRequestSchema } from "./invariant-report.js";
|
|
8
|
+
import { RoundStateSchema } from "./convergence.js";
|
|
9
|
+
import { ProviderRegistrationSchema } from "./provider-registration.js";
|
|
14
10
|
function parseOrThrow(schema, input, label) {
|
|
15
11
|
const result = schema.safeParse(input);
|
|
16
12
|
if (result.success) {
|
|
17
13
|
return result.data;
|
|
18
14
|
}
|
|
19
|
-
throw
|
|
15
|
+
throw schemaErrorFrom(label, result.error);
|
|
20
16
|
}
|
|
21
17
|
export function parseEvidencePack(input) {
|
|
22
18
|
return parseOrThrow(EvidencePackSchema, input, "evidence pack");
|
|
@@ -37,7 +33,7 @@ export function parseEvidencePackRead(input) {
|
|
|
37
33
|
if (result.success) {
|
|
38
34
|
return result.data;
|
|
39
35
|
}
|
|
40
|
-
throw
|
|
36
|
+
throw schemaErrorFrom("evidence pack", result.error);
|
|
41
37
|
}
|
|
42
38
|
export function parseDecisionLogEntry(input) {
|
|
43
39
|
return parseOrThrow(DecisionLogEntrySchema, input, "decision log entry");
|
|
@@ -54,4 +50,16 @@ export function parseDimensionContext(input) {
|
|
|
54
50
|
export function parseDimensionContextInput(input) {
|
|
55
51
|
return parseOrThrow(DimensionContextInputSchema, input, "dimension context input");
|
|
56
52
|
}
|
|
53
|
+
export function parseInvariantReport(input) {
|
|
54
|
+
return parseOrThrow(InvariantReportSchema, input, "invariant report");
|
|
55
|
+
}
|
|
56
|
+
export function parseReverificationRequest(input) {
|
|
57
|
+
return parseOrThrow(ReverificationRequestSchema, input, "re-verification request");
|
|
58
|
+
}
|
|
59
|
+
export function parseRoundState(input) {
|
|
60
|
+
return parseOrThrow(RoundStateSchema, input, "round state");
|
|
61
|
+
}
|
|
62
|
+
export function parseProviderRegistration(input) {
|
|
63
|
+
return parseOrThrow(ProviderRegistrationSchema, input, "provider registration");
|
|
64
|
+
}
|
|
57
65
|
//# sourceMappingURL=parse.js.map
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAyB,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAG5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,0BAA0B,EAE3B,MAAM,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;IACvD,OAAO,YAAY,CAAC,2BAA2B,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,YAAY,CAAC,qBAAqB,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,OAAO,YAAY,CAAC,2BAA2B,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,YAAY,CAAC,gBAAgB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,OAAO,YAAY,CAAC,0BAA0B,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The AE-provider registration contract (5.7 R40 scenario 5): a judgement producer
|
|
4
|
+
* registers once, and both harnesses consume it through the same shape.
|
|
5
|
+
*
|
|
6
|
+
* Why this is in the kernel rather than in each product: the alternative is two
|
|
7
|
+
* registries that describe the same provider differently, and the first time they
|
|
8
|
+
* disagree the run keeps going with whichever one happened to be consulted. The
|
|
9
|
+
* registration is metadata — who provides what, and what they need to do it — never
|
|
10
|
+
* the judgement itself, which stays in the engine and the reviewers.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROVIDER_SCHEMA_VERSION: "iterate.provider/0.1";
|
|
13
|
+
export declare const PROVIDER_ID_PATTERN: RegExp;
|
|
14
|
+
export declare const PROVIDER_ID_MAX_LENGTH = 64;
|
|
15
|
+
export declare const PROVIDER_METHOD_MAX = 32;
|
|
16
|
+
export declare const ProviderKindSchema: z.ZodEnum<["ae-diagnosis", "report-render", "evidence-source"]>;
|
|
17
|
+
export type ProviderKind = z.infer<typeof ProviderKindSchema>;
|
|
18
|
+
export declare const ProviderMethodSchema: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
/**
|
|
21
|
+
* What this method needs to run: capability names, not booleans per capability,
|
|
22
|
+
* so adding one does not require widening a schema on both sides. An empty list
|
|
23
|
+
* means "no prerequisites", which is a claim the provider has to make.
|
|
24
|
+
*/
|
|
25
|
+
requires: z.ZodArray<z.ZodString, "many">;
|
|
26
|
+
}, "strict", z.ZodTypeAny, {
|
|
27
|
+
name: string;
|
|
28
|
+
requires: string[];
|
|
29
|
+
}, {
|
|
30
|
+
name: string;
|
|
31
|
+
requires: string[];
|
|
32
|
+
}>;
|
|
33
|
+
export type ProviderMethod = z.infer<typeof ProviderMethodSchema>;
|
|
34
|
+
export declare const ProviderRegistrationSchema: z.ZodEffects<z.ZodObject<{
|
|
35
|
+
schemaVersion: z.ZodLiteral<"iterate.provider/0.1">;
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
kind: z.ZodEnum<["ae-diagnosis", "report-render", "evidence-source"]>;
|
|
38
|
+
version: z.ZodString;
|
|
39
|
+
/** Where it came from, so a consumer can tell first-party from installed. */
|
|
40
|
+
origin: z.ZodOptional<z.ZodEnum<["kernel", "glasspane", "iterate", "plugin"]>>;
|
|
41
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
/**
|
|
44
|
+
* What this method needs to run: capability names, not booleans per capability,
|
|
45
|
+
* so adding one does not require widening a schema on both sides. An empty list
|
|
46
|
+
* means "no prerequisites", which is a claim the provider has to make.
|
|
47
|
+
*/
|
|
48
|
+
requires: z.ZodArray<z.ZodString, "many">;
|
|
49
|
+
}, "strict", z.ZodTypeAny, {
|
|
50
|
+
name: string;
|
|
51
|
+
requires: string[];
|
|
52
|
+
}, {
|
|
53
|
+
name: string;
|
|
54
|
+
requires: string[];
|
|
55
|
+
}>, "many">;
|
|
56
|
+
}, "strict", z.ZodTypeAny, {
|
|
57
|
+
schemaVersion: "iterate.provider/0.1";
|
|
58
|
+
kind: "ae-diagnosis" | "report-render" | "evidence-source";
|
|
59
|
+
id: string;
|
|
60
|
+
version: string;
|
|
61
|
+
methods: {
|
|
62
|
+
name: string;
|
|
63
|
+
requires: string[];
|
|
64
|
+
}[];
|
|
65
|
+
origin?: "kernel" | "glasspane" | "iterate" | "plugin" | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
schemaVersion: "iterate.provider/0.1";
|
|
68
|
+
kind: "ae-diagnosis" | "report-render" | "evidence-source";
|
|
69
|
+
id: string;
|
|
70
|
+
version: string;
|
|
71
|
+
methods: {
|
|
72
|
+
name: string;
|
|
73
|
+
requires: string[];
|
|
74
|
+
}[];
|
|
75
|
+
origin?: "kernel" | "glasspane" | "iterate" | "plugin" | undefined;
|
|
76
|
+
}>, {
|
|
77
|
+
schemaVersion: "iterate.provider/0.1";
|
|
78
|
+
kind: "ae-diagnosis" | "report-render" | "evidence-source";
|
|
79
|
+
id: string;
|
|
80
|
+
version: string;
|
|
81
|
+
methods: {
|
|
82
|
+
name: string;
|
|
83
|
+
requires: string[];
|
|
84
|
+
}[];
|
|
85
|
+
origin?: "kernel" | "glasspane" | "iterate" | "plugin" | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
schemaVersion: "iterate.provider/0.1";
|
|
88
|
+
kind: "ae-diagnosis" | "report-render" | "evidence-source";
|
|
89
|
+
id: string;
|
|
90
|
+
version: string;
|
|
91
|
+
methods: {
|
|
92
|
+
name: string;
|
|
93
|
+
requires: string[];
|
|
94
|
+
}[];
|
|
95
|
+
origin?: "kernel" | "glasspane" | "iterate" | "plugin" | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
export type ProviderRegistration = z.infer<typeof ProviderRegistrationSchema>;
|
|
98
|
+
export declare const PROVIDER_CODES: {
|
|
99
|
+
readonly duplicateId: "KERNEL_E_PROVIDER_DUPLICATE";
|
|
100
|
+
readonly unknown: "KERNEL_E_PROVIDER_UNKNOWN";
|
|
101
|
+
readonly missingMethod: "KERNEL_E_PROVIDER_METHOD";
|
|
102
|
+
};
|
|
103
|
+
export type KernelProviderCode = (typeof PROVIDER_CODES)[keyof typeof PROVIDER_CODES];
|
|
104
|
+
export declare class KernelProviderError extends Error {
|
|
105
|
+
readonly code: KernelProviderCode;
|
|
106
|
+
readonly providerId: string;
|
|
107
|
+
readonly remedy: string;
|
|
108
|
+
constructor(code: KernelProviderCode, providerId: string, message: string, remedy: string);
|
|
109
|
+
}
|
|
110
|
+
export type ProviderRegistry = Readonly<Record<string, ProviderRegistration>>;
|
|
111
|
+
export declare function emptyProviderRegistry(): ProviderRegistry;
|
|
112
|
+
/**
|
|
113
|
+
* Add a provider, refusing to overwrite one.
|
|
114
|
+
*
|
|
115
|
+
* Returns a new registry rather than mutating: a half-applied registration (added to
|
|
116
|
+
* one map, rejected by the next) is how a provider disappears between two shells.
|
|
117
|
+
* Overwriting is refused rather than last-write-wins, because in a two-harness
|
|
118
|
+
* ecosystem a silent override means one product runs a provider the other never saw.
|
|
119
|
+
*/
|
|
120
|
+
export declare function registerProvider(registry: ProviderRegistry, provider: ProviderRegistration): ProviderRegistry;
|
|
121
|
+
/** Look a provider up. No default, no fuzzy match, no "the only one registered". */
|
|
122
|
+
export declare function resolveProvider(registry: ProviderRegistry, id: string): ProviderRegistration;
|
|
123
|
+
export declare function requireMethod(registry: ProviderRegistry, id: string, method: string): ProviderMethod;
|
|
124
|
+
/**
|
|
125
|
+
* Assert two registries do not shadow each other.
|
|
126
|
+
*
|
|
127
|
+
* Each harness keeps its own providers; what must not happen is the same id meaning
|
|
128
|
+
* two different things across the boundary, because then "the AE provider" names a
|
|
129
|
+
* different judgement in each product while both look satisfied.
|
|
130
|
+
*/
|
|
131
|
+
export declare function providerIdsInCommon(a: ProviderRegistry, b: ProviderRegistry): string[];
|
|
132
|
+
//# sourceMappingURL=provider-registration.d.ts.map
|