@reticlehq/core 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/artifacts/flow-constants.d.ts +19 -0
- package/dist/artifacts/flow-constants.js +36 -1
- package/dist/artifacts/flow-expect-flat.d.ts +16 -16
- package/dist/artifacts/flow-expect-flat.js +2 -2
- package/dist/artifacts/flow-mutation-target.js +4 -0
- package/dist/artifacts/flow-types.d.ts +393 -297
- package/dist/artifacts/flow-types.js +17 -2
- package/dist/artifacts/journal.d.ts +3 -2
- package/dist/hooks/hook-events.d.ts +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/registry/daemon-registry.d.ts +14 -4
- package/dist/registry/daemon-registry.js +20 -4
- package/dist/schema/event-payloads.json +3 -0
- package/dist/telemetry-refusal.d.ts +3 -2
- package/dist/telemetry.d.ts +17 -16
- package/dist/telemetry.js +3 -3
- package/dist/verdict/compare-source.d.ts +80 -0
- package/dist/verdict/compare-source.js +93 -0
- package/dist/verdict/consequence.d.ts +2 -0
- package/dist/verdict/consequence.js +2 -0
- package/dist/verdict/instrumentation-gap.js +1 -1
- package/dist/verdict/intent.d.ts +12 -12
- package/dist/verdict/predicate-tree.d.ts +35 -0
- package/dist/verdict/predicate-tree.js +40 -0
- package/dist/verdict/predicate.d.ts +11 -2
- package/dist/verdict/predicate.js +38 -2
- package/dist/verdict/verification-run.d.ts +261 -28
- package/dist/verdict/verification-run.js +36 -0
- package/dist/wire/channel.d.ts +10 -0
- package/dist/wire/channel.js +25 -0
- package/dist/wire/constants/constants.d.ts +45 -5
- package/dist/wire/constants/constants.js +57 -5
- package/dist/wire/event-payloads.d.ts +12 -9
- package/dist/wire/event-payloads.js +8 -3
- package/dist/wire/messages.d.ts +24 -24
- package/dist/wire/net.d.ts +17 -0
- package/dist/wire/net.js +17 -0
- package/dist/wire/redaction.js +17 -0
- package/dist/wire/toon.d.ts +1 -1
- package/dist/wire/toon.js +2 -1
- package/dist/wire/types.d.ts +44 -44
- package/dist/words/no-session-reason.d.ts +7 -0
- package/dist/words/no-session-reason.js +7 -0
- package/dist/words/notices.d.ts +7 -0
- package/dist/words/notices.js +9 -2
- package/package.json +3 -2
package/dist/verdict/intent.d.ts
CHANGED
|
@@ -39,12 +39,12 @@ export declare const IntentSurfaceSchema: z.ZodObject<{
|
|
|
39
39
|
flow: z.ZodOptional<z.ZodString>;
|
|
40
40
|
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
flow?: string | undefined;
|
|
43
42
|
route?: string | undefined;
|
|
43
|
+
flow?: string | undefined;
|
|
44
44
|
files?: string[] | undefined;
|
|
45
45
|
}, {
|
|
46
|
-
flow?: string | undefined;
|
|
47
46
|
route?: string | undefined;
|
|
47
|
+
flow?: string | undefined;
|
|
48
48
|
files?: string[] | undefined;
|
|
49
49
|
}>;
|
|
50
50
|
export type IntentSurface = z.infer<typeof IntentSurfaceSchema>;
|
|
@@ -75,12 +75,12 @@ export declare const IntentSchema: z.ZodObject<{
|
|
|
75
75
|
flow: z.ZodOptional<z.ZodString>;
|
|
76
76
|
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
77
77
|
}, "strip", z.ZodTypeAny, {
|
|
78
|
-
flow?: string | undefined;
|
|
79
78
|
route?: string | undefined;
|
|
79
|
+
flow?: string | undefined;
|
|
80
80
|
files?: string[] | undefined;
|
|
81
81
|
}, {
|
|
82
|
-
flow?: string | undefined;
|
|
83
82
|
route?: string | undefined;
|
|
83
|
+
flow?: string | undefined;
|
|
84
84
|
files?: string[] | undefined;
|
|
85
85
|
}>>;
|
|
86
86
|
provenBy: z.ZodOptional<z.ZodObject<{
|
|
@@ -113,8 +113,8 @@ export declare const IntentSchema: z.ZodObject<{
|
|
|
113
113
|
statement: string;
|
|
114
114
|
declaredAt: number;
|
|
115
115
|
surface?: {
|
|
116
|
-
flow?: string | undefined;
|
|
117
116
|
route?: string | undefined;
|
|
117
|
+
flow?: string | undefined;
|
|
118
118
|
files?: string[] | undefined;
|
|
119
119
|
} | undefined;
|
|
120
120
|
binding?: unknown;
|
|
@@ -133,8 +133,8 @@ export declare const IntentSchema: z.ZodObject<{
|
|
|
133
133
|
statement: string;
|
|
134
134
|
declaredAt: number;
|
|
135
135
|
surface?: {
|
|
136
|
-
flow?: string | undefined;
|
|
137
136
|
route?: string | undefined;
|
|
137
|
+
flow?: string | undefined;
|
|
138
138
|
files?: string[] | undefined;
|
|
139
139
|
} | undefined;
|
|
140
140
|
binding?: unknown;
|
|
@@ -164,12 +164,12 @@ export declare const IntentFileSchema: z.ZodObject<{
|
|
|
164
164
|
flow: z.ZodOptional<z.ZodString>;
|
|
165
165
|
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
166
166
|
}, "strip", z.ZodTypeAny, {
|
|
167
|
-
flow?: string | undefined;
|
|
168
167
|
route?: string | undefined;
|
|
168
|
+
flow?: string | undefined;
|
|
169
169
|
files?: string[] | undefined;
|
|
170
170
|
}, {
|
|
171
|
-
flow?: string | undefined;
|
|
172
171
|
route?: string | undefined;
|
|
172
|
+
flow?: string | undefined;
|
|
173
173
|
files?: string[] | undefined;
|
|
174
174
|
}>>;
|
|
175
175
|
provenBy: z.ZodOptional<z.ZodObject<{
|
|
@@ -202,8 +202,8 @@ export declare const IntentFileSchema: z.ZodObject<{
|
|
|
202
202
|
statement: string;
|
|
203
203
|
declaredAt: number;
|
|
204
204
|
surface?: {
|
|
205
|
-
flow?: string | undefined;
|
|
206
205
|
route?: string | undefined;
|
|
206
|
+
flow?: string | undefined;
|
|
207
207
|
files?: string[] | undefined;
|
|
208
208
|
} | undefined;
|
|
209
209
|
binding?: unknown;
|
|
@@ -222,8 +222,8 @@ export declare const IntentFileSchema: z.ZodObject<{
|
|
|
222
222
|
statement: string;
|
|
223
223
|
declaredAt: number;
|
|
224
224
|
surface?: {
|
|
225
|
-
flow?: string | undefined;
|
|
226
225
|
route?: string | undefined;
|
|
226
|
+
flow?: string | undefined;
|
|
227
227
|
files?: string[] | undefined;
|
|
228
228
|
} | undefined;
|
|
229
229
|
binding?: unknown;
|
|
@@ -245,8 +245,8 @@ export declare const IntentFileSchema: z.ZodObject<{
|
|
|
245
245
|
statement: string;
|
|
246
246
|
declaredAt: number;
|
|
247
247
|
surface?: {
|
|
248
|
-
flow?: string | undefined;
|
|
249
248
|
route?: string | undefined;
|
|
249
|
+
flow?: string | undefined;
|
|
250
250
|
files?: string[] | undefined;
|
|
251
251
|
} | undefined;
|
|
252
252
|
binding?: unknown;
|
|
@@ -268,8 +268,8 @@ export declare const IntentFileSchema: z.ZodObject<{
|
|
|
268
268
|
statement: string;
|
|
269
269
|
declaredAt: number;
|
|
270
270
|
surface?: {
|
|
271
|
-
flow?: string | undefined;
|
|
272
271
|
route?: string | undefined;
|
|
272
|
+
flow?: string | undefined;
|
|
273
273
|
files?: string[] | undefined;
|
|
274
274
|
} | undefined;
|
|
275
275
|
binding?: unknown;
|
|
@@ -1,4 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a predicate's TOP-LEVEL clauses.
|
|
3
|
+
*
|
|
4
|
+
* Structural, not evaluative: these answer "what does this predicate say" from the shape alone, the
|
|
5
|
+
* same basis `predicateShapeFor` sits here on. Nothing here decides anything about an app.
|
|
6
|
+
*
|
|
7
|
+
* It lived beside the replay code until the journal's flow-naming needed it too, and a
|
|
8
|
+
* `journal -> flows` reach is a file filed in the wrong place rather than a dependency anybody
|
|
9
|
+
* wanted. The thing both callers want is a reader for a core type, so it lives with the type.
|
|
10
|
+
*
|
|
11
|
+
* v1 stored one slot per kind, so "does this step assert state?" was a property read and "drop the
|
|
12
|
+
* element clause" was a `delete`. A `Predicate` nests, so every one of those questions is a walk.
|
|
13
|
+
*
|
|
14
|
+
* The walks here are deliberately SHALLOW, and that is the whole design. A lifted v1 file produces
|
|
15
|
+
* either a single leaf or one flat `allOf`, so a top-level walk reproduces v1 behaviour exactly. A
|
|
16
|
+
* hand-written v2 predicate can nest arbitrarily, and going deeper would silently change what an
|
|
17
|
+
* existing flow asserts:
|
|
18
|
+
*
|
|
19
|
+
* - dropping a leaf from an `allOf` removes a conjunct, which is what v1's `delete` did;
|
|
20
|
+
* - dropping a branch from an `anyOf` removes an ALTERNATIVE, which makes the predicate STRICTER
|
|
21
|
+
* and can turn a passing flow red;
|
|
22
|
+
* - dropping anything under a `not` inverts the meaning of the thing you dropped.
|
|
23
|
+
*
|
|
24
|
+
* So the composite cases are handled where they mean what v1 meant, and left alone everywhere else.
|
|
25
|
+
*/
|
|
26
|
+
import { PredicateKind } from './consequence.js';
|
|
1
27
|
import type { Predicate } from './predicate.js';
|
|
28
|
+
/**
|
|
29
|
+
* The plain clause each side of a `compare` reads, so a walker that asks "which endpoints, signals,
|
|
30
|
+
* stores or elements does this predicate depend on?" answers for a comparison without learning its
|
|
31
|
+
* shape. They are READERS of the same channel, never claims: a compare's `net` side is not an
|
|
32
|
+
* assertion that some call succeeded, only that the comparison reads one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function compareSourceClauses(predicate: Extract<Predicate, {
|
|
35
|
+
kind: typeof PredicateKind.COMPARE;
|
|
36
|
+
}>): readonly Predicate[];
|
|
2
37
|
/** Every clause at the top level: the predicate itself, or the members of a top-level `allOf`. */
|
|
3
38
|
export declare function conjuncts(predicate: Predicate | undefined): readonly Predicate[];
|
|
4
39
|
/** The first top-level clause of this kind, or undefined. */
|
|
@@ -24,6 +24,34 @@
|
|
|
24
24
|
* So the composite cases are handled where they mean what v1 meant, and left alone everywhere else.
|
|
25
25
|
*/
|
|
26
26
|
import { PredicateKind } from './consequence.js';
|
|
27
|
+
/**
|
|
28
|
+
* The plain clause each side of a `compare` reads, so a walker that asks "which endpoints, signals,
|
|
29
|
+
* stores or elements does this predicate depend on?" answers for a comparison without learning its
|
|
30
|
+
* shape. They are READERS of the same channel, never claims: a compare's `net` side is not an
|
|
31
|
+
* assertion that some call succeeded, only that the comparison reads one.
|
|
32
|
+
*/
|
|
33
|
+
export function compareSourceClauses(predicate) {
|
|
34
|
+
return [predicate.left, predicate.right].map((source) => {
|
|
35
|
+
switch (source.from) {
|
|
36
|
+
case PredicateKind.NET:
|
|
37
|
+
return {
|
|
38
|
+
kind: PredicateKind.NET,
|
|
39
|
+
urlContains: source.urlContains,
|
|
40
|
+
...(source.method === undefined ? {} : { method: source.method }),
|
|
41
|
+
};
|
|
42
|
+
case PredicateKind.SIGNAL:
|
|
43
|
+
return { kind: PredicateKind.SIGNAL, name: source.name };
|
|
44
|
+
case PredicateKind.STATE:
|
|
45
|
+
return {
|
|
46
|
+
kind: PredicateKind.STATE,
|
|
47
|
+
path: source.path,
|
|
48
|
+
...(source.store === undefined ? {} : { store: source.store }),
|
|
49
|
+
};
|
|
50
|
+
case PredicateKind.TEXT:
|
|
51
|
+
return { kind: PredicateKind.TEXT, scope: source.scope };
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
27
55
|
/** Every clause at the top level: the predicate itself, or the members of a top-level `allOf`. */
|
|
28
56
|
export function conjuncts(predicate) {
|
|
29
57
|
if (predicate === undefined)
|
|
@@ -140,6 +168,18 @@ export function sessionBoundField(predicate) {
|
|
|
140
168
|
return ref('element.query.scope', predicate.query.scope);
|
|
141
169
|
case PredicateKind.ANIMATION:
|
|
142
170
|
return ref('animation.target', predicate.target);
|
|
171
|
+
case PredicateKind.COMPARE:
|
|
172
|
+
for (const [side, source] of [
|
|
173
|
+
['left', predicate.left],
|
|
174
|
+
['right', predicate.right],
|
|
175
|
+
]) {
|
|
176
|
+
if (PredicateKind.TEXT !== source.from)
|
|
177
|
+
continue;
|
|
178
|
+
const found = ref(`compare.${side}.scope`, source.scope);
|
|
179
|
+
if (found !== undefined)
|
|
180
|
+
return found;
|
|
181
|
+
}
|
|
182
|
+
return undefined;
|
|
143
183
|
default:
|
|
144
184
|
return undefined;
|
|
145
185
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import { type ElementQuery } from '../wire/types.js';
|
|
20
20
|
import { ElementState } from '../wire/constants/constants.js';
|
|
21
|
+
import { CompareAs, type CompareSource } from './compare-source.js';
|
|
21
22
|
import { PredicateKind } from './consequence.js';
|
|
22
23
|
import { type PropertyAssertion } from './property-assertion.js';
|
|
23
24
|
export type Predicate = {
|
|
@@ -61,11 +62,11 @@ export type Predicate = {
|
|
|
61
62
|
count?: number;
|
|
62
63
|
/** A substring the RESPONSE body must contain — what the server answered, not what was sent. */
|
|
63
64
|
bodyContains?: string;
|
|
64
|
-
/**
|
|
65
|
+
/** JSON field match over the RESPONSE body: this FIELD holds this value (#987). A key may be a dotted path. */
|
|
65
66
|
bodyMatches?: Record<string, unknown>;
|
|
66
67
|
/** A substring the REQUEST body must contain — what the UI sent, not what came back. */
|
|
67
68
|
requestBodyContains?: string;
|
|
68
|
-
/**
|
|
69
|
+
/** JSON field match over the REQUEST body, in the style of `signal.dataMatches`. */
|
|
69
70
|
requestBodyMatches?: Record<string, unknown>;
|
|
70
71
|
} | {
|
|
71
72
|
kind: typeof PredicateKind.ROUTE;
|
|
@@ -108,6 +109,14 @@ export type Predicate = {
|
|
|
108
109
|
} | {
|
|
109
110
|
kind: typeof PredicateKind.SETTLED;
|
|
110
111
|
quietMs?: number;
|
|
112
|
+
} | {
|
|
113
|
+
kind: typeof PredicateKind.COMPARE;
|
|
114
|
+
left: CompareSource;
|
|
115
|
+
right: CompareSource;
|
|
116
|
+
/** `value` (default): strict equality. `number`: one number read from each side. */
|
|
117
|
+
as?: CompareAs;
|
|
118
|
+
/** How far apart two numbers may be and still agree. Only with `as: "number"`. */
|
|
119
|
+
tolerance?: number;
|
|
111
120
|
} | {
|
|
112
121
|
kind: typeof PredicateKind.ALL_OF;
|
|
113
122
|
predicates: Predicate[];
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import { ElementQuerySchema } from '../wire/types.js';
|
|
20
20
|
import { ElementState } from '../wire/constants/constants.js';
|
|
21
|
+
import { CompareAs, CompareSourceSchema, sameCompareSource, } from './compare-source.js';
|
|
21
22
|
import { PredicateKind } from './consequence.js';
|
|
22
23
|
import { propertyAssertionSchema } from './property-assertion.js';
|
|
23
24
|
/**
|
|
@@ -197,7 +198,7 @@ function predicateUnion() {
|
|
|
197
198
|
*/
|
|
198
199
|
bodyContains: z.string().min(1).optional(),
|
|
199
200
|
/**
|
|
200
|
-
*
|
|
201
|
+
* JSON field match over the RESPONSE body, keyed like `signal.dataMatches` and sharing its
|
|
201
202
|
* `matchValue` operators (`*`, `$gte`, `$contains`, …) — the field-level half of
|
|
202
203
|
* `bodyContains` (#987).
|
|
203
204
|
*
|
|
@@ -235,7 +236,7 @@ function predicateUnion() {
|
|
|
235
236
|
*/
|
|
236
237
|
requestBodyContains: z.string().min(1).optional(),
|
|
237
238
|
/**
|
|
238
|
-
*
|
|
239
|
+
* JSON field match over the REQUEST body, keyed like `signal.dataMatches` and sharing its
|
|
239
240
|
* `matchValue` operators (`*`, `$gte`, `$contains`, …).
|
|
240
241
|
*
|
|
241
242
|
* `{ requestBodyMatches: { filter: "manual_review" } }` is the one-call verdict for "the UI
|
|
@@ -314,6 +315,15 @@ function predicateUnion() {
|
|
|
314
315
|
quietMs: z.number().positive().optional(),
|
|
315
316
|
})
|
|
316
317
|
.strict(),
|
|
318
|
+
z
|
|
319
|
+
.object({
|
|
320
|
+
kind: z.literal(PredicateKind.COMPARE),
|
|
321
|
+
left: CompareSourceSchema,
|
|
322
|
+
right: CompareSourceSchema,
|
|
323
|
+
as: z.enum([CompareAs.VALUE, CompareAs.NUMBER]).optional(),
|
|
324
|
+
tolerance: z.number().finite().nonnegative().optional(),
|
|
325
|
+
})
|
|
326
|
+
.strict(),
|
|
317
327
|
/*
|
|
318
328
|
* `.min(1)` on both combinators, because an EMPTY one is a false green and not an edge case.
|
|
319
329
|
*
|
|
@@ -355,6 +365,10 @@ function checkPredicateShape(predicate, ctx) {
|
|
|
355
365
|
if ('object' !== typeof predicate || null === predicate)
|
|
356
366
|
return;
|
|
357
367
|
const p = predicate;
|
|
368
|
+
if (PredicateKind.COMPARE === p.kind) {
|
|
369
|
+
checkCompareShape(predicate, ctx);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
358
372
|
if (PredicateKind.TEXT !== p.kind)
|
|
359
373
|
return;
|
|
360
374
|
if (undefined === p.contains && undefined === p.satisfies) {
|
|
@@ -374,6 +388,28 @@ function checkPredicateShape(predicate, ctx) {
|
|
|
374
388
|
});
|
|
375
389
|
}
|
|
376
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* The two ways a `compare` can be written so that it cannot fail, refused before it can report `yes`.
|
|
393
|
+
*
|
|
394
|
+
* A side compared with itself agrees with itself on every page, broken or not. And `tolerance` means
|
|
395
|
+
* nothing to a strict equality, so accepting it there would let a caller believe a band was applied.
|
|
396
|
+
*/
|
|
397
|
+
function checkCompareShape(p, ctx) {
|
|
398
|
+
if (sameCompareSource(p.left, p.right)) {
|
|
399
|
+
ctx.addIssue({
|
|
400
|
+
code: z.ZodIssueCode.custom,
|
|
401
|
+
message: '`left` and `right` read the same value, so this comparison agrees with itself on every ' +
|
|
402
|
+
'page and cannot fail. Compare two different readings: what the page shows against what ' +
|
|
403
|
+
'the server answered, or what was sent against what came back',
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
if (p.tolerance !== undefined && CompareAs.NUMBER !== p.as) {
|
|
407
|
+
ctx.addIssue({
|
|
408
|
+
code: z.ZodIssueCode.custom,
|
|
409
|
+
message: '`tolerance` applies to a numeric comparison only: add `as: "number"`',
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}
|
|
377
413
|
export const PredicateSchema = z.lazy(() => z.preprocess(applyPredicateAliases, predicateUnion()).superRefine(checkPredicateShape));
|
|
378
414
|
/**
|
|
379
415
|
* The fields one predicate kind accepts, as the schema itself declares them.
|