@reticlehq/engine 3.8.2 → 3.10.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/body-failures.js +16 -2
- package/dist/disagreement/contradiction-evidence.d.ts +119 -0
- package/dist/disagreement/contradiction-evidence.js +360 -48
- package/dist/disagreement/contradiction-types.d.ts +25 -0
- package/dist/disagreement/contradictions.d.ts +17 -1
- package/dist/disagreement/contradictions.js +146 -78
- package/dist/disagreement/echo-mismatch.js +205 -32
- package/dist/disagreement/stale-response.d.ts +10 -1
- package/dist/disagreement/stale-response.js +122 -47
- package/dist/evidence/already-true.d.ts +1 -1
- package/dist/evidence/already-true.js +13 -7
- package/dist/evidence/baseline.d.ts +1 -0
- package/dist/evidence/baseline.js +28 -12
- package/dist/evidence/blind-spots.d.ts +20 -3
- package/dist/evidence/blind-spots.js +127 -21
- package/dist/evidence/step-effect.d.ts +5 -0
- package/dist/evidence/step-effect.js +5 -2
- package/dist/evidence/verified.d.ts +23 -0
- package/dist/evidence/verified.js +53 -2
- package/dist/question/declared.d.ts +27 -0
- package/dist/question/declared.js +64 -13
- package/dist/question/predicate/net-blind-spots.d.ts +40 -1
- package/dist/question/predicate/net-blind-spots.js +110 -1
- package/dist/question/predicate/predicate-animation.d.ts +52 -0
- package/dist/question/predicate/predicate-animation.js +258 -0
- package/dist/question/predicate/predicate-compare.js +53 -26
- package/dist/question/predicate/predicate-element.d.ts +20 -2
- package/dist/question/predicate/predicate-element.js +207 -45
- package/dist/question/predicate/predicate-eval-kit.d.ts +2 -0
- package/dist/question/predicate/predicate-eval-kit.js +19 -0
- package/dist/question/predicate/predicate-eval.d.ts +1 -4
- package/dist/question/predicate/predicate-eval.js +41 -47
- package/dist/question/predicate/predicate-parse.js +132 -4
- package/dist/question/predicate/predicate-route.js +81 -27
- package/dist/question/predicate/predicate-schema.js +84 -34
- package/dist/question/predicate/predicate-session.d.ts +5 -0
- package/dist/question/predicate/predicate.js +119 -50
- package/dist/question/predicate/truncated-body-advice.d.ts +5 -0
- package/dist/question/predicate/truncated-body-advice.js +25 -0
- package/dist/state-bookkeeping.d.ts +24 -0
- package/dist/state-bookkeeping.js +31 -0
- package/dist/window/event-filters.d.ts +64 -0
- package/dist/window/event-filters.js +149 -20
- package/dist/window/network-detail-merge.d.ts +6 -0
- package/dist/window/network-detail-merge.js +43 -2
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementState, EventType, MUTATING_METHODS, PredicateKind, THROTTLED_STARVED_NOTE, isSameDocument, } from '@reticlehq/core';
|
|
1
|
+
import { ElementState, EventType, MUTATING_METHODS, PredicateKind, ReticleCommand, 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';
|
|
@@ -6,9 +6,16 @@ import { describeSuperseded } from './observed-in-window.js';
|
|
|
6
6
|
import { evalElement, textPredicateQuery, withTextProperty } from './predicate-element.js';
|
|
7
7
|
import { evalState } from './predicate-state.js';
|
|
8
8
|
import { evalCompare } from './predicate-compare.js';
|
|
9
|
-
import { PredicateSchema, evalNet, evalConsole,
|
|
9
|
+
import { PredicateSchema, evalNet, evalConsole, evalSignal, evalSettled, } from './predicate-eval.js';
|
|
10
|
+
import { evalAnimationPredicate } from './predicate-animation.js';
|
|
10
11
|
export { PredicateSchema, PredicateKind };
|
|
11
12
|
import { withinBudget } from './predicate-session.js';
|
|
13
|
+
const ANIMATION_RUNTIME = {
|
|
14
|
+
startEventType: EventType.ANIM_START,
|
|
15
|
+
endEventType: EventType.ANIM_END,
|
|
16
|
+
animationsCommand: ReticleCommand.ANIMATIONS,
|
|
17
|
+
targetArg: 'target',
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* A composite result that carries a child's "nobody could evaluate this" up to the verdict rule.
|
|
14
21
|
*
|
|
@@ -32,7 +39,6 @@ function unreadableComposite(child, evidence) {
|
|
|
32
39
|
const WINDOW_ONLY_KINDS = new Set([
|
|
33
40
|
PredicateKind.NET,
|
|
34
41
|
PredicateKind.CONSOLE,
|
|
35
|
-
PredicateKind.ANIMATION,
|
|
36
42
|
PredicateKind.SIGNAL,
|
|
37
43
|
PredicateKind.SETTLED,
|
|
38
44
|
]);
|
|
@@ -76,22 +82,28 @@ function predicateSince(predicate) {
|
|
|
76
82
|
* overwritten.
|
|
77
83
|
*/
|
|
78
84
|
function annotateThrottledMiss(session, predicate, result) {
|
|
79
|
-
if (result.pass)
|
|
85
|
+
if (result.pass) {
|
|
80
86
|
return result;
|
|
81
|
-
|
|
87
|
+
}
|
|
88
|
+
if (result.inconclusive !== undefined) {
|
|
82
89
|
return result;
|
|
90
|
+
}
|
|
83
91
|
const preconditionFailure = session.preconditionFailure?.();
|
|
84
92
|
if (preconditionFailure !== undefined) {
|
|
85
93
|
return { ...result, inconclusive: preconditionFailure };
|
|
86
94
|
}
|
|
87
|
-
if (true !== session.throttled?.())
|
|
95
|
+
if (true !== session.throttled?.()) {
|
|
88
96
|
return result;
|
|
89
|
-
|
|
97
|
+
}
|
|
98
|
+
if (decidedByAnAlreadyAnnotatedClause(predicate)) {
|
|
90
99
|
return result;
|
|
91
|
-
|
|
100
|
+
}
|
|
101
|
+
if (failureRestsOnSeeing(predicate)) {
|
|
92
102
|
return result;
|
|
93
|
-
|
|
103
|
+
}
|
|
104
|
+
if (evidenceProvesPageRendered(result)) {
|
|
94
105
|
return result;
|
|
106
|
+
}
|
|
95
107
|
return { ...result, inconclusive: THROTTLED_STARVED_NOTE };
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
@@ -114,12 +126,15 @@ function annotateThrottledMiss(session, predicate, result) {
|
|
|
114
126
|
*/
|
|
115
127
|
function evidenceProvesPageRendered(result) {
|
|
116
128
|
const evidence = result.evidence;
|
|
117
|
-
if ('object' !== typeof evidence || null === evidence)
|
|
129
|
+
if ('object' !== typeof evidence || null === evidence) {
|
|
118
130
|
return false;
|
|
119
|
-
|
|
131
|
+
}
|
|
132
|
+
if ('splitText' in evidence || 'caseMiss' in evidence) {
|
|
120
133
|
return true;
|
|
121
|
-
|
|
134
|
+
}
|
|
135
|
+
if ('nearMiss' in evidence && 'element.state' === result.assertion) {
|
|
122
136
|
return true;
|
|
137
|
+
}
|
|
123
138
|
return false;
|
|
124
139
|
}
|
|
125
140
|
/**
|
|
@@ -153,10 +168,12 @@ function decidedByAnAlreadyAnnotatedClause(predicate) {
|
|
|
153
168
|
* Composites recurse: a passing `allOf` proves a render if any of its own arms did.
|
|
154
169
|
*/
|
|
155
170
|
function provesRender(predicate, result) {
|
|
156
|
-
if (!result.pass)
|
|
171
|
+
if (!result.pass) {
|
|
157
172
|
return false;
|
|
158
|
-
|
|
173
|
+
}
|
|
174
|
+
if (PredicateKind.ELEMENT === predicate.kind) {
|
|
159
175
|
return true !== predicate.absent;
|
|
176
|
+
}
|
|
160
177
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
161
178
|
return predicate.predicates.some((p) => provesRender(p, result));
|
|
162
179
|
}
|
|
@@ -183,15 +200,51 @@ function clearStarvedWhenSiblingsSaw(predicates, results) {
|
|
|
183
200
|
const p = predicates[i];
|
|
184
201
|
return p !== undefined && provesRender(p, r);
|
|
185
202
|
});
|
|
186
|
-
if (!rendered)
|
|
203
|
+
if (!rendered) {
|
|
187
204
|
return results;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return rest;
|
|
205
|
+
}
|
|
206
|
+
return results.map((r, i) => {
|
|
207
|
+
const p = predicates[i];
|
|
208
|
+
return p === undefined ? r : clearStarved(p, r);
|
|
193
209
|
});
|
|
194
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* One arm without the starved-tab note.
|
|
213
|
+
*
|
|
214
|
+
* A `not` that was unreadable kept its child's result as evidence and never applied the negation.
|
|
215
|
+
* Dropping only the note left it at `pass: false`, which is the child's answer, not the negated
|
|
216
|
+
* one: a `not` of an absent element failed (reported on 3.8.2). So a `not` clears its child, then
|
|
217
|
+
* negates it again. Nested `not` recurses.
|
|
218
|
+
*/
|
|
219
|
+
function clearStarved(predicate, result) {
|
|
220
|
+
if (THROTTLED_STARVED_NOTE !== result.inconclusive) {
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
const child = result.evidence;
|
|
224
|
+
if (PredicateKind.NOT === predicate.kind && isEvalResult(child)) {
|
|
225
|
+
const inner = clearStarved(predicate.predicate, child);
|
|
226
|
+
return inner.inconclusive === undefined ? negate(predicate.predicate, inner) : result;
|
|
227
|
+
}
|
|
228
|
+
const { inconclusive: _dropped, ...rest } = result;
|
|
229
|
+
return rest;
|
|
230
|
+
}
|
|
231
|
+
/** A `not` keeps its child's result as its evidence. */
|
|
232
|
+
function isEvalResult(value) {
|
|
233
|
+
return ('object' === typeof value && null !== value && 'boolean' === typeof Reflect.get(value, 'pass'));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The `not` of a readable result.
|
|
237
|
+
*
|
|
238
|
+
* A green negation used to return a bare `{ pass: true }`, so the payload fell back to whatever
|
|
239
|
+
* the caller had — every element matching the OUTER locator. Three clauses negating three
|
|
240
|
+
* different names then produced byte-identical responses. The evidence is the whole answer here:
|
|
241
|
+
* what was looked for, and that it was not there.
|
|
242
|
+
*/
|
|
243
|
+
function negate(negated, inner) {
|
|
244
|
+
return inner.pass
|
|
245
|
+
? { pass: false, failureReason: 'negated predicate unexpectedly held', evidence: inner }
|
|
246
|
+
: { pass: true, evidence: { negated, held: false, saw: inner } };
|
|
247
|
+
}
|
|
195
248
|
/**
|
|
196
249
|
* Does this predicate FAIL by having seen something, rather than by not having seen it?
|
|
197
250
|
*
|
|
@@ -213,13 +266,15 @@ function clearStarvedWhenSiblingsSaw(predicates, results) {
|
|
|
213
266
|
* missing one costs a wrong verdict.
|
|
214
267
|
*/
|
|
215
268
|
function failureRestsOnSeeing(predicate) {
|
|
216
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
269
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
217
270
|
return !failureRestsOnSeeing(predicate.predicate);
|
|
271
|
+
}
|
|
218
272
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
219
273
|
return predicate.predicates.some(failureRestsOnSeeing);
|
|
220
274
|
}
|
|
221
|
-
if ('absent' in predicate && true === predicate.absent)
|
|
275
|
+
if ('absent' in predicate && true === predicate.absent) {
|
|
222
276
|
return true;
|
|
277
|
+
}
|
|
223
278
|
// `count: 0` is absence written as arithmetic, and fails the same way: by matching something.
|
|
224
279
|
return 'count' in predicate && 0 === predicate.count;
|
|
225
280
|
}
|
|
@@ -282,19 +337,26 @@ diagnose = true, baselines) {
|
|
|
282
337
|
// `scope` passes straight through: the text predicate has always been an element query with
|
|
283
338
|
// only `text` filled in, so scoping it needs the field, not a second code path.
|
|
284
339
|
const query = textPredicateQuery(predicate, session.sdkVersion);
|
|
285
|
-
const found = await evalElement(session, query, true === predicate.visible ? ElementState.VISIBLE : undefined, predicate.absent ?? false, diagnose
|
|
286
|
-
|
|
340
|
+
const found = await evalElement(session, query, true === predicate.visible ? ElementState.VISIBLE : undefined, predicate.absent ?? false, diagnose,
|
|
341
|
+
// A property is judged on the whole text, for an absence too: there only a match that
|
|
342
|
+
// satisfies it fails the check, and the matches come back re-bounded.
|
|
343
|
+
undefined !== predicate.satisfies, true === predicate.absent ? predicate.satisfies : undefined);
|
|
344
|
+
// An absence judged its property above, on each match.
|
|
345
|
+
if (undefined === predicate.satisfies || true === predicate.absent) {
|
|
287
346
|
return found;
|
|
347
|
+
}
|
|
288
348
|
return withTextProperty(found, predicate.satisfies, JSON.stringify(query), baselines?.get(predicate));
|
|
289
349
|
}
|
|
290
350
|
case PredicateKind.NET: {
|
|
291
|
-
const result = evalNet(events, predicate);
|
|
292
|
-
if (result.pass || keepsAnswers || result.inconclusive !== undefined)
|
|
351
|
+
const result = evalNet(events, predicate, session.sdkVersion);
|
|
352
|
+
if (result.pass || keepsAnswers || result.inconclusive !== undefined) {
|
|
293
353
|
return result;
|
|
354
|
+
}
|
|
294
355
|
// No floor, so a replaced page's answers were left out. If one would have satisfied the
|
|
295
356
|
// predicate, nothing here can say whether it was this action's: unknown, never a plain no.
|
|
296
357
|
const withAnswers = raw.filter((e) => onScreen(e) || isServerAnswer(e));
|
|
297
|
-
if (withAnswers.length === events.length ||
|
|
358
|
+
if (withAnswers.length === events.length ||
|
|
359
|
+
!evalNet(withAnswers, predicate, session.sdkVersion).pass) {
|
|
298
360
|
return result;
|
|
299
361
|
}
|
|
300
362
|
return {
|
|
@@ -310,7 +372,7 @@ diagnose = true, baselines) {
|
|
|
310
372
|
case PredicateKind.CONSOLE:
|
|
311
373
|
return evalConsole(events, predicate);
|
|
312
374
|
case PredicateKind.ANIMATION:
|
|
313
|
-
return
|
|
375
|
+
return evalAnimationPredicate(session, events, predicate, floor, ANIMATION_RUNTIME);
|
|
314
376
|
case PredicateKind.SIGNAL:
|
|
315
377
|
return evalSignal(events, predicate);
|
|
316
378
|
case PredicateKind.STATE:
|
|
@@ -350,20 +412,23 @@ diagnose = true, baselines) {
|
|
|
350
412
|
};
|
|
351
413
|
}
|
|
352
414
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
353
|
-
if (unreadable !== undefined)
|
|
415
|
+
if (unreadable !== undefined) {
|
|
354
416
|
return unreadableComposite(unreadable, results);
|
|
417
|
+
}
|
|
355
418
|
return { pass: true, evidence: results.map((r) => r.evidence) };
|
|
356
419
|
}
|
|
357
420
|
case PredicateKind.ANY_OF: {
|
|
358
421
|
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await Promise.all(predicate.predicates.map((p) => evaluatePredicate(session, p, since, diagnose, baselines))));
|
|
359
422
|
const passed = results.find((r) => r.pass);
|
|
360
|
-
if (passed !== undefined)
|
|
423
|
+
if (passed !== undefined) {
|
|
361
424
|
return { pass: true, evidence: passed.evidence };
|
|
425
|
+
}
|
|
362
426
|
// "No sub-predicate matched" is a claim anyOf is not entitled to make while one of them was
|
|
363
427
|
// never read: the unreadable clause might have been the one that would have matched.
|
|
364
428
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
365
|
-
if (unreadable !== undefined)
|
|
429
|
+
if (unreadable !== undefined) {
|
|
366
430
|
return unreadableComposite(unreadable, results);
|
|
431
|
+
}
|
|
367
432
|
// A disjunction is decided when EVERY clause is permanently false: no branch can
|
|
368
433
|
// ever become true, so waiting out the budget buys nothing. By this point every
|
|
369
434
|
// result is a non-inconclusive failure (passing and inconclusive returned above).
|
|
@@ -381,16 +446,10 @@ diagnose = true, baselines) {
|
|
|
381
446
|
// child's `pass: false` as "the inner predicate did not hold" and passed — so an assertion
|
|
382
447
|
// nobody could evaluate became a verdict of verified, manufactured out of a missing reading.
|
|
383
448
|
// You cannot negate an answer nobody had.
|
|
384
|
-
if (inner.inconclusive !== undefined)
|
|
449
|
+
if (inner.inconclusive !== undefined) {
|
|
385
450
|
return unreadableComposite(inner, inner);
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
// three different names then produced byte-identical responses, which reads as a checker that
|
|
389
|
-
// dropped the name rather than one that correctly found all three absent. The evidence is the
|
|
390
|
-
// whole answer here: what was looked for, and that it was not there.
|
|
391
|
-
return inner.pass
|
|
392
|
-
? { pass: false, failureReason: 'negated predicate unexpectedly held', evidence: inner }
|
|
393
|
-
: { pass: true, evidence: { negated: predicate.predicate, held: false, saw: inner } };
|
|
451
|
+
}
|
|
452
|
+
return negate(predicate.predicate, inner);
|
|
394
453
|
}
|
|
395
454
|
default:
|
|
396
455
|
return { pass: false, failureReason: 'unknown predicate' };
|
|
@@ -448,8 +507,9 @@ function assertsExactCount(predicate) {
|
|
|
448
507
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
449
508
|
return predicate.predicates.some(assertsExactCount);
|
|
450
509
|
}
|
|
451
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
510
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
452
511
|
return assertsExactCount(predicate.predicate);
|
|
512
|
+
}
|
|
453
513
|
// `signal` carries `count` for the same reason `net` does, and for the same defect: its schema
|
|
454
514
|
// calls the double-fire "the defect no state-only oracle can see", because a handler wired twice
|
|
455
515
|
// leaves the store in the right shape and a presence check green on both. Reading `net` alone
|
|
@@ -467,8 +527,9 @@ function assertsExactCount(predicate) {
|
|
|
467
527
|
* once the page ran slower. It holds until the page goes quiet; see ABSENCE_HOLD_MS.
|
|
468
528
|
*/
|
|
469
529
|
function claimsAbsence(predicate) {
|
|
470
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
530
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
471
531
|
return true;
|
|
532
|
+
}
|
|
472
533
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
473
534
|
return predicate.predicates.some(claimsAbsence);
|
|
474
535
|
}
|
|
@@ -528,20 +589,24 @@ baselines) {
|
|
|
528
589
|
});
|
|
529
590
|
};
|
|
530
591
|
const finish = (result) => {
|
|
531
|
-
if (done)
|
|
592
|
+
if (done) {
|
|
532
593
|
return;
|
|
594
|
+
}
|
|
533
595
|
done = true;
|
|
534
596
|
releaseWindow?.();
|
|
535
597
|
unsub();
|
|
536
598
|
unsubDisconnect?.();
|
|
537
599
|
clearInterval(interval);
|
|
538
600
|
clearTimeout(timer);
|
|
539
|
-
if (cooldownTimer !== undefined)
|
|
601
|
+
if (cooldownTimer !== undefined) {
|
|
540
602
|
clearTimeout(cooldownTimer);
|
|
541
|
-
|
|
603
|
+
}
|
|
604
|
+
if (hintTimer !== undefined) {
|
|
542
605
|
clearTimeout(hintTimer);
|
|
543
|
-
|
|
606
|
+
}
|
|
607
|
+
if (confirmTimer !== undefined) {
|
|
544
608
|
clearTimeout(confirmTimer);
|
|
609
|
+
}
|
|
545
610
|
resolve(result);
|
|
546
611
|
};
|
|
547
612
|
// Coalesce re-checks: at most ONE evaluatePredicate is ever in flight (each can be a browser
|
|
@@ -558,8 +623,9 @@ baselines) {
|
|
|
558
623
|
let cooling = false;
|
|
559
624
|
let pendingRecheck = false;
|
|
560
625
|
const check = () => {
|
|
561
|
-
if (done)
|
|
626
|
+
if (done) {
|
|
562
627
|
return;
|
|
628
|
+
}
|
|
563
629
|
if (inFlight || cooling) {
|
|
564
630
|
pendingRecheck = true;
|
|
565
631
|
return;
|
|
@@ -597,8 +663,9 @@ baselines) {
|
|
|
597
663
|
finish(r);
|
|
598
664
|
return;
|
|
599
665
|
}
|
|
600
|
-
if (confirming)
|
|
666
|
+
if (confirming) {
|
|
601
667
|
return;
|
|
668
|
+
}
|
|
602
669
|
confirming = true;
|
|
603
670
|
const confirm = () => {
|
|
604
671
|
void evaluatePredicate(reader, predicate, since, true, baselines)
|
|
@@ -616,8 +683,9 @@ baselines) {
|
|
|
616
683
|
const holdUntilQuiet = () => {
|
|
617
684
|
void evaluatePredicate(reader, SETTLED_PROBE, since, false)
|
|
618
685
|
.then((settled) => {
|
|
619
|
-
if (done)
|
|
686
|
+
if (done) {
|
|
620
687
|
return;
|
|
688
|
+
}
|
|
621
689
|
if (settled.pass) {
|
|
622
690
|
confirm();
|
|
623
691
|
return;
|
|
@@ -633,8 +701,9 @@ baselines) {
|
|
|
633
701
|
})
|
|
634
702
|
.finally(() => {
|
|
635
703
|
inFlight = false;
|
|
636
|
-
if (done)
|
|
704
|
+
if (done) {
|
|
637
705
|
return;
|
|
706
|
+
}
|
|
638
707
|
// Enter a short cooldown; process a coalesced recheck when it ends. The 150ms poll is the
|
|
639
708
|
// backstop, so a missed trailing edge is caught within one interval regardless.
|
|
640
709
|
cooling = true;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to keep more of a truncated body. On an SDK that predates the option, raising it changes
|
|
3
|
+
* nothing, so the only advice that works is updating the SDK: say that instead (#2031).
|
|
4
|
+
*/
|
|
5
|
+
export declare function truncatedBodyAdvice(sdkVersion: string | undefined, missedMatch: boolean): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What to do about a response body that was truncated before it was recorded, for the inconclusive
|
|
3
|
+
* verdict `evalNet` gives when the wanted body is not in the kept part.
|
|
4
|
+
*/
|
|
5
|
+
import { sdkPredates } from './predicate-eval-kit.js';
|
|
6
|
+
/** A truncated body missed a `bodyContains`: the kept prefix can still answer a substring. */
|
|
7
|
+
const TRUNCATED_PREFIX_REMEDY = "Raise it past this response's size and re-run, or assert on something inside the recorded prefix";
|
|
8
|
+
/**
|
|
9
|
+
* A truncated body missed a `bodyMatches`. That clause parses the whole body and a JSON prefix never
|
|
10
|
+
* parses, so "assert inside the prefix" changes nothing for it (#1417): name what can work instead.
|
|
11
|
+
*/
|
|
12
|
+
const TRUNCATED_MATCHES_REMEDY = "Raise it past this response's size and re-run. `bodyMatches` parses the whole body, and a JSON prefix never parses, so it cannot be judged on the kept part: to assert on what was kept, use `bodyContains` with a substring from it";
|
|
13
|
+
/** The first SDK release that reads `networkBodyMaxChars`; an older one caps every body at 8192 (#2031). */
|
|
14
|
+
const BODY_MAX_CHARS_SINCE = '3.3.0';
|
|
15
|
+
/**
|
|
16
|
+
* How to keep more of a truncated body. On an SDK that predates the option, raising it changes
|
|
17
|
+
* nothing, so the only advice that works is updating the SDK: say that instead (#2031).
|
|
18
|
+
*/
|
|
19
|
+
export function truncatedBodyAdvice(sdkVersion, missedMatch) {
|
|
20
|
+
const remedy = missedMatch ? TRUNCATED_MATCHES_REMEDY : TRUNCATED_PREFIX_REMEDY;
|
|
21
|
+
if (sdkPredates(sdkVersion, BODY_MAX_CHARS_SINCE)) {
|
|
22
|
+
return `This page's SDK ${String(sdkVersion)} caps every recorded body at 8192 characters and ignores \`networkBodyMaxChars\`, which arrived in ${BODY_MAX_CHARS_SINCE}, so raising it changes nothing yet. Run \`reticle update\` in the app's folder, then restart its dev server. After that the cap is \`networkBodyMaxChars\`, set where the app calls connect(). ${remedy}`;
|
|
23
|
+
}
|
|
24
|
+
return `The cap is per-body and set where the app calls connect(): \`reticle.connect({ captureNetworkBodies: true, networkBodyMaxChars: 65536 })\`, or for the Vite plugin \`reticle({ networkBodyMaxChars: 65536 })\` / VITE_RETICLE_BODY_MAX_CHARS=65536 (default 8192, max 262144). An SDK older than this daemon ignores the option; a version skew on the session says so. ${remedy}`;
|
|
25
|
+
}
|
|
@@ -25,3 +25,27 @@ export declare function isCacheBookkeepingDiff(from: unknown, to: unknown): bool
|
|
|
25
25
|
export declare function isMeaningfulStateChange(event: ReticleEvent): boolean;
|
|
26
26
|
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
27
27
|
export declare const isReticleVoice: (name: string) => boolean;
|
|
28
|
+
/** What the rule needs to know about an event. The caller supplies it, so this file reads no wire shape. */
|
|
29
|
+
interface AppReaction<E> {
|
|
30
|
+
/** Which store path or signal the event moved, or undefined when it moved neither. */
|
|
31
|
+
keyOf: (event: E) => string | undefined;
|
|
32
|
+
/** Whether the caller's predicate named this change. */
|
|
33
|
+
isNamed: (event: E) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A store change or an app signal that can be TIED to the action (#1531).
|
|
37
|
+
*
|
|
38
|
+
* The app's own state moving is a reaction, the same as a request, even when the DOM update it
|
|
39
|
+
* drives lands after the window was read: a Pause button whose store changes on the media `pause`
|
|
40
|
+
* event. But being in the window is not enough. The session stamps the active action's id on every
|
|
41
|
+
* event between dispatch and settle, so a busy page's background store updates look attributed
|
|
42
|
+
* too, and a dead click among them must still be reported ("no-effect under ambient churn").
|
|
43
|
+
*
|
|
44
|
+
* So a change counts only when it is tied to the action in one of two ways:
|
|
45
|
+
* - the caller's predicate named it (a `state` path or a `signal` name), so it is the consequence
|
|
46
|
+
* they expected; or
|
|
47
|
+
* - it was quiet before the action: `prior` holds observations, and none of them moved this path
|
|
48
|
+
* or fired this signal. Churn that was already moving is the background, not this click.
|
|
49
|
+
*/
|
|
50
|
+
export declare function tiedReaction<E>(prior: readonly E[], { keyOf, isNamed }: AppReaction<E>): (event: E) => boolean;
|
|
51
|
+
export {};
|
|
@@ -72,3 +72,34 @@ export function isMeaningfulStateChange(event) {
|
|
|
72
72
|
const RETICLE_VOICE = /^(?:reticle:|__reticle)/;
|
|
73
73
|
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
74
74
|
export const isReticleVoice = (name) => RETICLE_VOICE.test(name);
|
|
75
|
+
/**
|
|
76
|
+
* A store change or an app signal that can be TIED to the action (#1531).
|
|
77
|
+
*
|
|
78
|
+
* The app's own state moving is a reaction, the same as a request, even when the DOM update it
|
|
79
|
+
* drives lands after the window was read: a Pause button whose store changes on the media `pause`
|
|
80
|
+
* event. But being in the window is not enough. The session stamps the active action's id on every
|
|
81
|
+
* event between dispatch and settle, so a busy page's background store updates look attributed
|
|
82
|
+
* too, and a dead click among them must still be reported ("no-effect under ambient churn").
|
|
83
|
+
*
|
|
84
|
+
* So a change counts only when it is tied to the action in one of two ways:
|
|
85
|
+
* - the caller's predicate named it (a `state` path or a `signal` name), so it is the consequence
|
|
86
|
+
* they expected; or
|
|
87
|
+
* - it was quiet before the action: `prior` holds observations, and none of them moved this path
|
|
88
|
+
* or fired this signal. Churn that was already moving is the background, not this click.
|
|
89
|
+
*/
|
|
90
|
+
export function tiedReaction(prior, { keyOf, isNamed }) {
|
|
91
|
+
const movedBefore = new Set();
|
|
92
|
+
for (const event of prior) {
|
|
93
|
+
const key = keyOf(event);
|
|
94
|
+
if (key !== undefined) {
|
|
95
|
+
movedBefore.add(key);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return (event) => {
|
|
99
|
+
const key = keyOf(event);
|
|
100
|
+
if (key === undefined) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return isNamed(event) || (prior.length > 0 && !movedBefore.has(key));
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -64,6 +64,13 @@ interface NetCallView {
|
|
|
64
64
|
* which is the reading that turns an unverifiable call into an assumed success.
|
|
65
65
|
*/
|
|
66
66
|
oneWay?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The document before this one made this request, and the daemon carried it here (#1944). Its
|
|
69
|
+
* place in the list is when this document connected, not when the request happened.
|
|
70
|
+
*/
|
|
71
|
+
fromDepartedDocument?: boolean;
|
|
72
|
+
/** Its page unloaded before the answer arrived: the outcome is unknown, not failed (#1944). */
|
|
73
|
+
pageUnloaded?: boolean;
|
|
67
74
|
}
|
|
68
75
|
export declare function projectNetCall(e: ReticleEvent, includeBodies?: boolean): NetCallView;
|
|
69
76
|
/**
|
|
@@ -118,4 +125,61 @@ interface ConsoleEmptyHint {
|
|
|
118
125
|
byLevel: ConsoleLevelCounts;
|
|
119
126
|
}
|
|
120
127
|
export declare function consoleEmptyHint(allConsole: ReticleEvent[]): ConsoleEmptyHint;
|
|
128
|
+
/**
|
|
129
|
+
* Did the browser leave for a URL this filter names, inside the window (#1936)?
|
|
130
|
+
*
|
|
131
|
+
* A click on `<a download>`, or on a link that the server answers as an attachment, is recorded as a
|
|
132
|
+
* navigation `NET_PENDING`. The response goes to the download manager. The page never sees its
|
|
133
|
+
* status, and no `NET_REQUEST` can close the record. A miss over this window is unobservable, not a
|
|
134
|
+
* failure: the file can be on disk while the net channel shows only the pending record.
|
|
135
|
+
*
|
|
136
|
+
* An ordinary link records the same navigation `NET_PENDING`, and there the page DID leave, so a
|
|
137
|
+
* miss stays a real `no`. A record counts only when it is a download (`download: true`), or when no
|
|
138
|
+
* later event comes from a different document. A later event with another `documentId` proves that
|
|
139
|
+
* a new document loaded, so the old page's request did not go to a download.
|
|
140
|
+
*/
|
|
141
|
+
export declare function departedInWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Did a request to this URL leave through a `fetch` that Reticle did not patch, in the window?
|
|
144
|
+
*
|
|
145
|
+
* The SDK reports such a call as `net.unpatched`: the browser recorded it in resource timing, and no
|
|
146
|
+
* patched transport saw it. It has no method, so only the URL filter can match it.
|
|
147
|
+
*/
|
|
148
|
+
export declare function unpatchedInWindow(events: readonly ReticleEvent[], since: number, urlContains: string | undefined): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Did the page send a request this filter names, inside the window, and unload before its answer
|
|
151
|
+
* arrived (#1944)? The daemon marks such a carried `NET_PENDING` `pageUnloaded`. Its outcome is
|
|
152
|
+
* unknown, so a miss over it is unobservable, not a failure.
|
|
153
|
+
*/
|
|
154
|
+
export declare function unloadedInWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The media entry that matches this filter and was recorded BEFORE the window opened, if any.
|
|
157
|
+
*
|
|
158
|
+
* The browser observer reports only the first resource timing entry for a URL: its seen-set
|
|
159
|
+
* (`reportedNetUrls` in adapters/realm/browser/src/observers/network.ts) drops every later entry
|
|
160
|
+
* for a URL it has already reported. For a media element load that first entry is also the only
|
|
161
|
+
* kind of record there is, so once it lands before `since`, a repeat load inside the window
|
|
162
|
+
* leaves no record at all and the window reads empty. The empty window is then not evidence the
|
|
163
|
+
* file did not load in it — a missing entry is not evidence there (#2069).
|
|
164
|
+
*
|
|
165
|
+
* A `fetch` or XHR record before the window impeaches nothing and is not returned here: the
|
|
166
|
+
* patched transports report every call, so a repeat would have been seen. Only the clauses that
|
|
167
|
+
* identify the request are read — `urlContains` and `method`. A status clause is not read: the
|
|
168
|
+
* entry's status is the unreadable thing this blind spot is about. Resource timing carries no
|
|
169
|
+
* method; the observer stamps `GET` for exactly that reason, so a record with no method counts
|
|
170
|
+
* as the `GET` a media element only ever issues.
|
|
171
|
+
*/
|
|
172
|
+
export declare function mediaEntryBeforeWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): ReticleEvent | undefined;
|
|
173
|
+
/** A `confirm` or `prompt` that Reticle answered for the app, as the window recorded it. */
|
|
174
|
+
export interface DeclinedDialog {
|
|
175
|
+
readonly kind: string;
|
|
176
|
+
readonly message?: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The first dialog in the window that Reticle answered on the app's behalf, or undefined.
|
|
180
|
+
*
|
|
181
|
+
* Only a dialog that carries `answered` counts. An `alert` has no answer, so it cannot change which
|
|
182
|
+
* path the app took. The SDK and the leased-tab pool both record the answer in this one event.
|
|
183
|
+
*/
|
|
184
|
+
export declare function declinedDialogIn(events: readonly ReticleEvent[]): DeclinedDialog | undefined;
|
|
121
185
|
export {};
|