@reticlehq/engine 3.7.0 → 3.8.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/dist/disagreement/contradiction-evidence.d.ts +70 -3
- package/dist/disagreement/contradiction-evidence.js +156 -7
- package/dist/disagreement/contradiction-types.d.ts +8 -0
- package/dist/disagreement/contradictions.js +21 -16
- package/dist/disagreement/stale-response.js +49 -15
- package/dist/evidence/baseline.js +1 -1
- package/dist/evidence/body-capture-remedy.d.ts +1 -15
- package/dist/evidence/body-capture-remedy.js +6 -1
- package/dist/evidence/step-effect.d.ts +20 -1
- package/dist/evidence/step-effect.js +30 -2
- package/dist/evidence/uncaptured-bodies.d.ts +18 -1
- package/dist/evidence/uncaptured-bodies.js +22 -1
- package/dist/evidence/unread-outcome.d.ts +7 -0
- package/dist/evidence/unread-outcome.js +22 -0
- package/dist/evidence/unsettled.js +25 -0
- package/dist/evidence/verified.d.ts +2 -0
- package/dist/evidence/verified.js +1 -1
- package/dist/question/predicate/predicate-compare.js +7 -1
- package/dist/question/predicate/predicate-console.js +23 -10
- package/dist/question/predicate/predicate-element.d.ts +10 -1
- package/dist/question/predicate/predicate-element.js +138 -17
- package/dist/question/predicate/predicate-eval-kit.d.ts +3 -3
- package/dist/question/predicate/predicate-eval-kit.js +3 -7
- package/dist/question/predicate/predicate-eval.d.ts +10 -0
- package/dist/question/predicate/predicate-eval.js +91 -10
- package/dist/question/predicate/predicate-request-body.d.ts +9 -0
- package/dist/question/predicate/predicate-request-body.js +16 -1
- package/dist/question/predicate/predicate.js +54 -8
- package/dist/question/predicate/split-text-miss.d.ts +1 -0
- package/dist/question/predicate/split-text-miss.js +8 -1
- package/dist/state-bookkeeping.d.ts +2 -0
- package/dist/state-bookkeeping.js +4 -0
- package/dist/window/adversary.js +5 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EventType, NetInitiator, PredicateKind, StreamDirection, isDevToolingUrl, isForeignTraffic, urlForMatch, REDACTED_VALUE, } from '@reticlehq/core';
|
|
1
|
+
import { EventType, NetInitiator, PredicateKind, ResponseBodyReason, SettledChannel, StreamDirection, isDevToolingUrl, isForeignTraffic, urlForMatch, REDACTED_VALUE, } from '@reticlehq/core';
|
|
2
|
+
import { isReticleVoice } from '../../state-bookkeeping.js';
|
|
2
3
|
import { describeObserved } from './observed-in-window.js';
|
|
3
4
|
import { netEvidence } from './net-evidence.js';
|
|
4
5
|
import { checkRequestBody, newRequestBodyState, requestBodyVerdict, } from './predicate-request-body.js';
|
|
@@ -162,6 +163,37 @@ function observerSawSubresources(events) {
|
|
|
162
163
|
function wantedBody(p) {
|
|
163
164
|
return JSON.stringify(p.bodyContains ?? p.bodyMatches);
|
|
164
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* The remedy for a body the SDK skipped ON PURPOSE with capture on, or `undefined` (#1520).
|
|
168
|
+
*
|
|
169
|
+
* Shared by every message that would otherwise say "enable captureNetworkBodies": that advice is
|
|
170
|
+
* wrong when capture is already on and the body was a stream, a binary type, or a read that did
|
|
171
|
+
* not finish. `undefined` means no reason was stamped: capture was off, or the SDK predates it.
|
|
172
|
+
*/
|
|
173
|
+
export function skippedBodyRemedy(reason) {
|
|
174
|
+
if (ResponseBodyReason.STREAMING === reason) {
|
|
175
|
+
return 'The body was streamed (text/event-stream or ndjson): the SDK never reads a stream, because reading it would hang the app, and capture is already on. Assert the result in the DOM or in state instead, or use a non-streaming endpoint.';
|
|
176
|
+
}
|
|
177
|
+
if (ResponseBodyReason.NOT_TEXT === reason) {
|
|
178
|
+
return 'The body is not text (binary, or a content type that is not recorded), and capture is already on. Assert the result in the DOM or in state instead.';
|
|
179
|
+
}
|
|
180
|
+
if (ResponseBodyReason.UNREADABLE === reason) {
|
|
181
|
+
return 'The body could not be read before the read deadline, and capture is already on. A response that is still streaming does this. Assert the result in the DOM or in state instead.';
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
/** The skip reason every one of these calls carries, when they all carry the same one. */
|
|
186
|
+
export function sharedSkipReason(reasons) {
|
|
187
|
+
const [first] = reasons;
|
|
188
|
+
if (first === undefined)
|
|
189
|
+
return undefined;
|
|
190
|
+
return reasons.every((r) => r === first) ? first : undefined;
|
|
191
|
+
}
|
|
192
|
+
/** Why a matched call's body could not answer a body clause, and what to do instead (#1520). */
|
|
193
|
+
function unrecordedBodyReason(p, reason) {
|
|
194
|
+
const head = `a call matching ${describeNetFilter(p)} was answered, but its body was not recorded, so ${wantedBody(p)} could not be checked, which is not the same as absent.`;
|
|
195
|
+
return `${head} ${skippedBodyRemedy(reason) ?? 'Enable it where the app calls connect(): reticle({ captureNetworkBodies: true })'}`;
|
|
196
|
+
}
|
|
165
197
|
export function evalNet(events, p) {
|
|
166
198
|
const since = p.since ?? 0;
|
|
167
199
|
/**
|
|
@@ -178,6 +210,8 @@ export function evalNet(events, p) {
|
|
|
178
210
|
* because it is the same pass over the same events.
|
|
179
211
|
*/
|
|
180
212
|
let matchedButUnrecorded = false;
|
|
213
|
+
/** Why the SDK skipped that body, when it said (#1520). Absent: capture off, or an older SDK. */
|
|
214
|
+
let unrecordedReason;
|
|
181
215
|
/** A call matched url/method but carried NO readable status (document-initiated subresource). */
|
|
182
216
|
let unobservableStatus = false;
|
|
183
217
|
/**
|
|
@@ -242,6 +276,7 @@ export function evalNet(events, p) {
|
|
|
242
276
|
const response = str(d['responseBody']);
|
|
243
277
|
if (response === undefined) {
|
|
244
278
|
matchedButUnrecorded = true;
|
|
279
|
+
unrecordedReason ??= d['responseBodyReason'];
|
|
245
280
|
return false;
|
|
246
281
|
}
|
|
247
282
|
// A needle missing from a body we only hold the FIRST N BYTES of is undecidable, not absent:
|
|
@@ -292,9 +327,13 @@ export function evalNet(events, p) {
|
|
|
292
327
|
};
|
|
293
328
|
}
|
|
294
329
|
if (matchedButUnrecorded && 0 === matches.length) {
|
|
330
|
+
// Inconclusive, never a plain failure: nothing says the body lacked the text, only that nobody
|
|
331
|
+
// read it (#1520). The same family as evicted evidence answering `no` (#1231).
|
|
332
|
+
const reason = unrecordedBodyReason(p, unrecordedReason);
|
|
295
333
|
return {
|
|
296
334
|
pass: false,
|
|
297
|
-
failureReason:
|
|
335
|
+
failureReason: reason,
|
|
336
|
+
inconclusive: reason,
|
|
298
337
|
observed: 'a matching call with no recorded body',
|
|
299
338
|
expected: `a body carrying ${wantedBody(p)}`,
|
|
300
339
|
assertion: NetBodyAssertion.CONTAINS,
|
|
@@ -425,7 +464,9 @@ export function evalAnimation(events, p) {
|
|
|
425
464
|
const hit = events.find((e) => {
|
|
426
465
|
if (e.type !== wantType)
|
|
427
466
|
return false;
|
|
428
|
-
|
|
467
|
+
const name = str(e.data['name']);
|
|
468
|
+
// A check with no name asks about the app, so Reticle's own bookkeeping signals do not count.
|
|
469
|
+
if (p.name === undefined ? isReticleVoice(name ?? '') : name !== p.name)
|
|
429
470
|
return false;
|
|
430
471
|
if (p.target !== undefined && e.ref !== p.target)
|
|
431
472
|
return false;
|
|
@@ -451,7 +492,9 @@ export function evalSignal(events, p) {
|
|
|
451
492
|
const isMatch = (e) => {
|
|
452
493
|
if (e.type !== EventType.SIGNAL)
|
|
453
494
|
return false;
|
|
454
|
-
|
|
495
|
+
const name = str(e.data['name']);
|
|
496
|
+
// A check with no name asks about the app, so Reticle's own bookkeeping signals do not count.
|
|
497
|
+
if (p.name === undefined ? isReticleVoice(name ?? '') : name !== p.name)
|
|
455
498
|
return false;
|
|
456
499
|
if (p.dataMatches !== undefined) {
|
|
457
500
|
const payload = (e.data['data'] ?? {});
|
|
@@ -556,6 +599,10 @@ const SETTLE_ACTIVITY = new Set([
|
|
|
556
599
|
EventType.DOM_REMOVED,
|
|
557
600
|
EventType.DOM_ATTR,
|
|
558
601
|
]);
|
|
602
|
+
/** An app-scoped settle: the default's activity, and every framework render commit. */
|
|
603
|
+
const APP_ACTIVITY = new Set([...SETTLE_ACTIVITY, EventType.RENDER_COMMIT]);
|
|
604
|
+
/** The quiet window of a network-scoped settle: a completed request is the only activity. */
|
|
605
|
+
const NETWORK_ACTIVITY = new Set([EventType.NET_REQUEST]);
|
|
559
606
|
/** The three net-shaped event types a URL can be read off — the only ones dev tooling can produce. */
|
|
560
607
|
const NET_TYPES = new Set([
|
|
561
608
|
EventType.NET_PENDING,
|
|
@@ -564,6 +611,8 @@ const NET_TYPES = new Set([
|
|
|
564
611
|
]);
|
|
565
612
|
/** Default quiet window — enough to absorb a render+xhr settle without waiting on slow polls. */
|
|
566
613
|
const DEFAULT_QUIET_MS = 500;
|
|
614
|
+
/** Work the app declared (`reticle.busy`; core's `RETICLE_BUSY_SIGNAL`); not imported: coupling only shrinks. */
|
|
615
|
+
const RETICLE_BUSY_SIGNAL = 'reticle:busy';
|
|
567
616
|
/**
|
|
568
617
|
* Did the browser LEAVE for this record, rather than make a request whose result we will see?
|
|
569
618
|
*
|
|
@@ -694,12 +743,35 @@ export function evalSettled(allEvents, p, now, scope) {
|
|
|
694
743
|
openStreams.delete(id);
|
|
695
744
|
}
|
|
696
745
|
const streaming = openStreams.size;
|
|
746
|
+
// Work only the app can see (`reticle.busy`): starts minus ends, in order, never below zero, so an
|
|
747
|
+
// end whose start fell before this window is not credit against work started inside it.
|
|
748
|
+
let appBusy = 0;
|
|
749
|
+
for (const e of events) {
|
|
750
|
+
if (e.type !== EventType.SIGNAL || RETICLE_BUSY_SIGNAL !== e.data['name'])
|
|
751
|
+
continue;
|
|
752
|
+
const delta = e.data['data']?.delta;
|
|
753
|
+
if ('number' === typeof delta)
|
|
754
|
+
appBusy = Math.max(0, appBusy + Math.sign(delta));
|
|
755
|
+
}
|
|
756
|
+
if (appBusy > 0 && 0 === inFlight + streaming) {
|
|
757
|
+
const what = `${String(appBusy)} app task(s) still pending`;
|
|
758
|
+
return {
|
|
759
|
+
pass: false,
|
|
760
|
+
failureReason: `not settled: ${what}`,
|
|
761
|
+
observed: what,
|
|
762
|
+
expected: 'no work the app declared still pending',
|
|
763
|
+
assertion: 'settled.app-busy',
|
|
764
|
+
evidence: { settled: false, appBusy, ...disclosure },
|
|
765
|
+
};
|
|
766
|
+
}
|
|
697
767
|
if (inFlight + streaming > 0) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
768
|
+
let what = `${String(inFlight)} request(s) in flight and ${String(streaming)} response body(ies) still streaming`;
|
|
769
|
+
if (0 === streaming) {
|
|
770
|
+
what = `${String(inFlight)} request(s) still in flight`;
|
|
771
|
+
}
|
|
772
|
+
else if (0 === inFlight) {
|
|
773
|
+
what = `${String(streaming)} response body(ies) still streaming`;
|
|
774
|
+
}
|
|
703
775
|
return {
|
|
704
776
|
pass: false,
|
|
705
777
|
failureReason: `not settled: ${what}`,
|
|
@@ -714,10 +786,19 @@ export function evalSettled(allEvents, p, now, scope) {
|
|
|
714
786
|
},
|
|
715
787
|
};
|
|
716
788
|
}
|
|
789
|
+
// A network-scoped settle reads only completed requests for the quiet window; the in-flight checks
|
|
790
|
+
// above already ran for every scope.
|
|
791
|
+
let activity = SETTLE_ACTIVITY;
|
|
792
|
+
if (SettledChannel.NETWORK === p.channel) {
|
|
793
|
+
activity = NETWORK_ACTIVITY;
|
|
794
|
+
}
|
|
795
|
+
else if (SettledChannel.APP === p.channel) {
|
|
796
|
+
activity = APP_ACTIVITY;
|
|
797
|
+
}
|
|
717
798
|
let lastT = -1;
|
|
718
799
|
let lastType;
|
|
719
800
|
for (const e of events) {
|
|
720
|
-
if (
|
|
801
|
+
if (activity.has(e.type) && e.t > lastT) {
|
|
721
802
|
lastT = e.t;
|
|
722
803
|
lastType = e.type;
|
|
723
804
|
}
|
|
@@ -19,6 +19,8 @@ interface RequestBodyPredicate {
|
|
|
19
19
|
interface RequestBodyState {
|
|
20
20
|
/** A call matched everything else but carried no recorded request body. */
|
|
21
21
|
unrecorded: boolean;
|
|
22
|
+
/** The body type the SDK named for an unrecorded request body, which it does only with capture on. */
|
|
23
|
+
unrecordedType?: unknown;
|
|
22
24
|
/** The request body a clause was checked against and did not match. */
|
|
23
25
|
mismatch?: string;
|
|
24
26
|
/** The prefix of a TRUNCATED request body the clause did not hold over — undecidable, not absent. */
|
|
@@ -33,6 +35,13 @@ interface RequestBodyState {
|
|
|
33
35
|
*/
|
|
34
36
|
redactedField?: string;
|
|
35
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The remedy for a request body the SDK did not record although capture is on, or `undefined`.
|
|
40
|
+
*
|
|
41
|
+
* With capture on, the SDK names the type of a body it cannot stringify (`requestBodyType`: a
|
|
42
|
+
* `Blob`, a `FormData`, a stream). "Enable captureNetworkBodies" is then wrong advice (#1520).
|
|
43
|
+
*/
|
|
44
|
+
export declare function requestBodySkipRemedy(bodyType: unknown): string | undefined;
|
|
36
45
|
export declare function newRequestBodyState(): RequestBodyState;
|
|
37
46
|
/**
|
|
38
47
|
* Does this event satisfy the predicate's request-body clauses? Records why not in `state`.
|
|
@@ -15,6 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { REDACTED_VALUE } from '@reticlehq/core';
|
|
17
17
|
import { clipBody, describeBodyFieldMiss, describeNetFilter, matchJsonBody, str, } from './predicate-eval-kit.js';
|
|
18
|
+
/**
|
|
19
|
+
* The remedy for a request body the SDK did not record although capture is on, or `undefined`.
|
|
20
|
+
*
|
|
21
|
+
* With capture on, the SDK names the type of a body it cannot stringify (`requestBodyType`: a
|
|
22
|
+
* `Blob`, a `FormData`, a stream). "Enable captureNetworkBodies" is then wrong advice (#1520).
|
|
23
|
+
*/
|
|
24
|
+
export function requestBodySkipRemedy(bodyType) {
|
|
25
|
+
if ('string' !== typeof bodyType || 0 === bodyType.length)
|
|
26
|
+
return undefined;
|
|
27
|
+
return `the request body was a ${bodyType}, which the SDK does not record as text, and capture is already on. Assert on the response or on the effect the request had instead`;
|
|
28
|
+
}
|
|
18
29
|
export function newRequestBodyState() {
|
|
19
30
|
return { unrecorded: false };
|
|
20
31
|
}
|
|
@@ -30,6 +41,7 @@ export function checkRequestBody(data, predicate, state) {
|
|
|
30
41
|
const sent = str(data['requestBody']);
|
|
31
42
|
if (sent === undefined) {
|
|
32
43
|
state.unrecorded = true;
|
|
44
|
+
state.unrecordedType ??= data['requestBodyType'];
|
|
33
45
|
return false;
|
|
34
46
|
}
|
|
35
47
|
const wasTruncated = true === data['requestBodyTruncated'];
|
|
@@ -83,9 +95,12 @@ export function requestBodyVerdict(state, predicate, matchCount, responseMismatc
|
|
|
83
95
|
};
|
|
84
96
|
}
|
|
85
97
|
if (state.unrecorded) {
|
|
98
|
+
// Unknown, not different: nothing was read, so nothing says the body did not match (#1520).
|
|
99
|
+
const reason = `a call matched but its REQUEST body was not recorded, so the request-body clause could not be checked — ${requestBodySkipRemedy(state.unrecordedType) ?? 'enable it where the app calls connect(): reticle({ captureNetworkBodies: true })'}`;
|
|
86
100
|
return {
|
|
87
101
|
pass: false,
|
|
88
|
-
failureReason:
|
|
102
|
+
failureReason: reason,
|
|
103
|
+
inconclusive: reason,
|
|
89
104
|
observed: 'a matching call with no recorded request body',
|
|
90
105
|
expected: `a request body matching ${wanted}`,
|
|
91
106
|
assertion: 'net.requestBody',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementState, PredicateKind, THROTTLED_STARVED_NOTE, isSameDocument, } from '@reticlehq/core';
|
|
1
|
+
import { ElementState, EventType, MUTATING_METHODS, PredicateKind, THROTTLED_STARVED_NOTE, isSameDocument, } from '@reticlehq/core';
|
|
2
2
|
import { predicateToExpectedLinks } from './predicate-to-links.js';
|
|
3
3
|
import { isAmbient, ambientKeyOf } from '../../window/ambient.js';
|
|
4
4
|
import { evalRoute } from './predicate-route.js';
|
|
@@ -38,6 +38,25 @@ const WINDOW_ONLY_KINDS = new Set([
|
|
|
38
38
|
]);
|
|
39
39
|
/** Names the oracle that answered, in the same shape every other `assertion` here uses. */
|
|
40
40
|
const SUPERSEDED_ASSERTION = 'window.evidence-superseded';
|
|
41
|
+
/**
|
|
42
|
+
* A WRITE the server answered: a mutating NET_REQUEST carrying a status or an `ok`.
|
|
43
|
+
*
|
|
44
|
+
* The answer to a write is a fact about the server, not page state, so it stays true after the
|
|
45
|
+
* page that sent it is replaced (#1529). The answer to a read is not: a GET from the old page says
|
|
46
|
+
* nothing about whether the page now on screen loaded its data, and keeping it would let a stale
|
|
47
|
+
* 200 pass `net GET 200` while the current page's own request failed. A request nobody answered,
|
|
48
|
+
* or a subresource whose answer could not be read, carries neither field and is never kept.
|
|
49
|
+
*/
|
|
50
|
+
function isServerAnswer(e) {
|
|
51
|
+
const method = e.data['method'];
|
|
52
|
+
return (EventType.NET_REQUEST === e.type &&
|
|
53
|
+
'string' === typeof method &&
|
|
54
|
+
MUTATING_METHODS.includes(method.toUpperCase()) &&
|
|
55
|
+
('number' === typeof e.data['status'] || 'boolean' === typeof e.data['ok']));
|
|
56
|
+
}
|
|
57
|
+
/** Why a `net` miss is unknown when only a replaced page's answer would have matched (#1529). */
|
|
58
|
+
const ANSWERED_BEFORE_NAVIGATION = 'a matching request was answered under the page before the navigation, and this window has no ' +
|
|
59
|
+
'`since` floor to count it in. Pass the cursor from before the action as `since`.';
|
|
41
60
|
/** The predicate's own event-time floor, if its kind carries one. */
|
|
42
61
|
function predicateSince(predicate) {
|
|
43
62
|
return 'since' in predicate && 'number' === typeof predicate.since ? predicate.since : 0;
|
|
@@ -226,11 +245,19 @@ diagnose = true, baselines) {
|
|
|
226
245
|
// `since` from the act it just performed is scoping the assertion to that action's aftermath. It is
|
|
227
246
|
// applied here, once, rather than in each eval: the floor means the same thing for every kind that
|
|
228
247
|
// reads the event stream, and net/console re-applying it is a no-op.
|
|
229
|
-
const
|
|
248
|
+
const floor = Math.max(since, predicateSince(predicate));
|
|
249
|
+
const raw = session.eventsSince(floor);
|
|
250
|
+
const onScreen = (e) => isSameDocument(e.documentId, session.currentDocumentId);
|
|
230
251
|
// Scoped ONCE, here, for the same reason the contradiction pass scopes at its own choke point:
|
|
231
252
|
// reasoning about a dead page's evidence is a defect in every oracle below rather than in whichever
|
|
232
253
|
// one happened to read it, and this is the single place they all take their window from.
|
|
233
|
-
|
|
254
|
+
//
|
|
255
|
+
// One exception (#1529). A `net` predicate inside an explicit `since` window also keeps the server's
|
|
256
|
+
// answers to the page that was just replaced: a write that navigates (delete, then redirect home)
|
|
257
|
+
// is proven by its response, and dropping it read a 204 as "never happened". The floor is what
|
|
258
|
+
// ties the request to the action; without one it could come from any earlier page.
|
|
259
|
+
const keepsAnswers = PredicateKind.NET === predicate.kind && 0 < floor;
|
|
260
|
+
const events = raw.filter((e) => onScreen(e) || (keepsAnswers && isServerAnswer(e)));
|
|
234
261
|
const superseded = raw.length - events.length;
|
|
235
262
|
// An empty window was always allowed to mean "it did not happen"; that reading is only unsafe once
|
|
236
263
|
// supersession is what emptied it. Without this, dropping stale evidence would trade a wrong pass
|
|
@@ -254,14 +281,28 @@ diagnose = true, baselines) {
|
|
|
254
281
|
case PredicateKind.TEXT: {
|
|
255
282
|
// `scope` passes straight through: the text predicate has always been an element query with
|
|
256
283
|
// only `text` filled in, so scoping it needs the field, not a second code path.
|
|
257
|
-
const query = textPredicateQuery(predicate);
|
|
284
|
+
const query = textPredicateQuery(predicate, session.sdkVersion);
|
|
258
285
|
const found = await evalElement(session, query, true === predicate.visible ? ElementState.VISIBLE : undefined, predicate.absent ?? false, diagnose);
|
|
259
286
|
if (undefined === predicate.satisfies)
|
|
260
287
|
return found;
|
|
261
288
|
return withTextProperty(found, predicate.satisfies, JSON.stringify(query), baselines?.get(predicate));
|
|
262
289
|
}
|
|
263
|
-
case PredicateKind.NET:
|
|
264
|
-
|
|
290
|
+
case PredicateKind.NET: {
|
|
291
|
+
const result = evalNet(events, predicate);
|
|
292
|
+
if (result.pass || keepsAnswers || result.inconclusive !== undefined)
|
|
293
|
+
return result;
|
|
294
|
+
// No floor, so a replaced page's answers were left out. If one would have satisfied the
|
|
295
|
+
// predicate, nothing here can say whether it was this action's: unknown, never a plain no.
|
|
296
|
+
const withAnswers = raw.filter((e) => onScreen(e) || isServerAnswer(e));
|
|
297
|
+
if (withAnswers.length === events.length || !evalNet(withAnswers, predicate).pass) {
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
...result,
|
|
302
|
+
failureReason: ANSWERED_BEFORE_NAVIGATION,
|
|
303
|
+
inconclusive: ANSWERED_BEFORE_NAVIGATION,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
265
306
|
case PredicateKind.ROUTE:
|
|
266
307
|
// `since` so an unanswered request already in flight before this window is not counted
|
|
267
308
|
// against the app — see unansweredIn.
|
|
@@ -418,7 +459,7 @@ function assertsExactCount(predicate) {
|
|
|
418
459
|
predicate.count !== undefined);
|
|
419
460
|
}
|
|
420
461
|
/**
|
|
421
|
-
* Does this predicate claim that something did NOT happen: an `absent` check, or a `not`?
|
|
462
|
+
* Does this predicate claim that something did NOT happen: an `absent` check, a `count: 0`, or a `not`?
|
|
422
463
|
*
|
|
423
464
|
* Such a claim is about the END of a window for the same reason an exact count is, and reads true
|
|
424
465
|
* at the start of every window by construction. Settled on its first reading, a clean-console check
|
|
@@ -431,7 +472,12 @@ function claimsAbsence(predicate) {
|
|
|
431
472
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
432
473
|
return predicate.predicates.some(claimsAbsence);
|
|
433
474
|
}
|
|
434
|
-
|
|
475
|
+
if ('absent' in predicate && true === predicate.absent) {
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
// `count: 0` is absence written as arithmetic. Held only for COUNT_CONFIRM_MS, a request sent
|
|
479
|
+
// 500 ms after the action passed a "no request" check.
|
|
480
|
+
return 'count' in predicate && 0 === predicate.count;
|
|
435
481
|
}
|
|
436
482
|
/**
|
|
437
483
|
* Evaluate now, else wait for it to become true (on each event + a poll) until timeout. `since` is
|
|
@@ -38,7 +38,14 @@ export function describeSplitTextMiss(owner, searchedText) {
|
|
|
38
38
|
if (owner === undefined)
|
|
39
39
|
return undefined;
|
|
40
40
|
const where = nameOf(owner);
|
|
41
|
-
|
|
41
|
+
// A selector wins over the ref: it can be written into an `until` before the action runs,
|
|
42
|
+
// which is when the recovery has to exist. A ref is minted by a snapshot the agent may not
|
|
43
|
+
// have taken yet (#1147).
|
|
44
|
+
const scope = owner.selector !== undefined && owner.selector.length > 0
|
|
45
|
+
? owner.selector
|
|
46
|
+
: owner.ref !== undefined && owner.ref.length > 0
|
|
47
|
+
? owner.ref
|
|
48
|
+
: undefined;
|
|
42
49
|
const recovery = scope === undefined || searchedText === undefined
|
|
43
50
|
? 'scope to that container and match it as a whole'
|
|
44
51
|
: `retry as ${JSON.stringify({
|
|
@@ -23,3 +23,5 @@ export declare const CACHE_BOOKKEEPING_KEYS: ReadonlySet<string>;
|
|
|
23
23
|
export declare function isCacheBookkeepingDiff(from: unknown, to: unknown): boolean;
|
|
24
24
|
/** Whether a state event carries movement that can support state-vs-render. */
|
|
25
25
|
export declare function isMeaningfulStateChange(event: ReticleEvent): boolean;
|
|
26
|
+
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
27
|
+
export declare const isReticleVoice: (name: string) => boolean;
|
|
@@ -68,3 +68,7 @@ export function isMeaningfulStateChange(event) {
|
|
|
68
68
|
const after = 'value' in event.data ? event.data['value'] : event.data['new'];
|
|
69
69
|
return !isCacheBookkeepingDiff(event.data['old'], after);
|
|
70
70
|
}
|
|
71
|
+
/** The name prefixes of Reticle's own signals and stores (`reticle:busy`, `__reticle…`). */
|
|
72
|
+
const RETICLE_VOICE = /^(?:reticle:|__reticle)/;
|
|
73
|
+
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
74
|
+
export const isReticleVoice = (name) => RETICLE_VOICE.test(name);
|
package/dist/window/adversary.js
CHANGED
|
@@ -45,6 +45,9 @@ function barestValue(schema) {
|
|
|
45
45
|
return false;
|
|
46
46
|
case 'ZodArray':
|
|
47
47
|
return [];
|
|
48
|
+
// A tuple has a fixed length, so the barest one still has every item.
|
|
49
|
+
case 'ZodTuple':
|
|
50
|
+
return (def.items ?? []).map((item) => barestValue(item));
|
|
48
51
|
case 'ZodLiteral':
|
|
49
52
|
return def.value;
|
|
50
53
|
case 'ZodEnum':
|
|
@@ -67,8 +70,9 @@ function barestObject(schema) {
|
|
|
67
70
|
const out = {};
|
|
68
71
|
for (const [key, field] of Object.entries(schema.shape)) {
|
|
69
72
|
const value = barestValue(field);
|
|
70
|
-
if (value !== undefined)
|
|
73
|
+
if (value !== undefined) {
|
|
71
74
|
out[key] = value;
|
|
75
|
+
}
|
|
72
76
|
}
|
|
73
77
|
return out;
|
|
74
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "The rules that decide a verdict: read what happened in a running app and say whether the declared consequence held. No browser, no daemon, no command line - an implementation of the OpenVerification specification you can use on its own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verification",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"zod": "^3.24.1",
|
|
60
|
-
"@reticlehq/core": "3.
|
|
60
|
+
"@reticlehq/core": "3.8.0",
|
|
61
61
|
"open-verification": "1.0.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|