@reticlehq/engine 3.9.0 → 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.
Files changed (43) hide show
  1. package/dist/disagreement/body-failures.js +16 -2
  2. package/dist/disagreement/contradiction-evidence.d.ts +119 -0
  3. package/dist/disagreement/contradiction-evidence.js +360 -48
  4. package/dist/disagreement/contradiction-types.d.ts +25 -0
  5. package/dist/disagreement/contradictions.d.ts +17 -1
  6. package/dist/disagreement/contradictions.js +146 -78
  7. package/dist/disagreement/echo-mismatch.js +205 -32
  8. package/dist/disagreement/stale-response.d.ts +10 -1
  9. package/dist/disagreement/stale-response.js +122 -47
  10. package/dist/evidence/already-true.d.ts +1 -1
  11. package/dist/evidence/already-true.js +13 -7
  12. package/dist/evidence/baseline.d.ts +1 -0
  13. package/dist/evidence/baseline.js +27 -16
  14. package/dist/evidence/blind-spots.d.ts +20 -3
  15. package/dist/evidence/blind-spots.js +127 -21
  16. package/dist/evidence/step-effect.d.ts +5 -0
  17. package/dist/evidence/step-effect.js +5 -2
  18. package/dist/evidence/verified.d.ts +23 -0
  19. package/dist/evidence/verified.js +53 -2
  20. package/dist/question/declared.d.ts +27 -0
  21. package/dist/question/declared.js +64 -13
  22. package/dist/question/predicate/net-blind-spots.d.ts +37 -1
  23. package/dist/question/predicate/net-blind-spots.js +72 -1
  24. package/dist/question/predicate/predicate-animation.d.ts +52 -0
  25. package/dist/question/predicate/predicate-animation.js +258 -0
  26. package/dist/question/predicate/predicate-element.d.ts +5 -2
  27. package/dist/question/predicate/predicate-element.js +103 -33
  28. package/dist/question/predicate/predicate-eval-kit.d.ts +2 -0
  29. package/dist/question/predicate/predicate-eval-kit.js +19 -0
  30. package/dist/question/predicate/predicate-eval.d.ts +1 -4
  31. package/dist/question/predicate/predicate-eval.js +38 -46
  32. package/dist/question/predicate/predicate-route.js +81 -27
  33. package/dist/question/predicate/predicate-schema.js +11 -2
  34. package/dist/question/predicate/predicate.js +79 -40
  35. package/dist/question/predicate/truncated-body-advice.d.ts +5 -0
  36. package/dist/question/predicate/truncated-body-advice.js +25 -0
  37. package/dist/state-bookkeeping.d.ts +24 -0
  38. package/dist/state-bookkeeping.js +31 -0
  39. package/dist/window/event-filters.d.ts +64 -0
  40. package/dist/window/event-filters.js +149 -20
  41. package/dist/window/network-detail-merge.d.ts +6 -0
  42. package/dist/window/network-detail-merge.js +43 -2
  43. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
- import { ContradictionKind, EventType, isAbsenceDerived, isSameDocument, isSameEditEpoch, } from '@reticlehq/core';
1
+ import { neverAnswered, ContradictionKind, EventType, isAbsenceDerived, isSameDocument, isSameEditEpoch, } from '@reticlehq/core';
2
2
  import { describeSuperseded } from '../question/predicate/observed-in-window.js';
3
- import { declareFailureHint, describe, groupByIdentity, identityOf, isMutating, isSameDocumentHashAnchor, isSamePathnameReplace, isSteadyCadence, appIsSilent, netCall, TargetFate, targetFate, pageNumber, pageRequest, recoveredByRetry, screenMoved, splitForeignTraffic, } from './contradiction-evidence.js';
3
+ import { declareFailureHint, describe, didNothing, RETICLE_SIGNAL_NAMESPACE, groupByIdentity, identityOf, isMutating, isSameDocumentHashAnchor, isSamePathnameReplace, isSteadyCadence, appIsSilent, CanvasPaint, canvasPaint, liveAlertAfterFailedSend, netCall, TargetFate, targetFate, pageNumber, pageRequest, recoveredByRetry, screenMoved, splitForeignTraffic, storeEchoesFailedStatus, successClaims, UNNAMED_SIGNAL, } from './contradiction-evidence.js';
4
4
  import { findStaleResponses } from './stale-response.js';
5
5
  import { findBodyFailures } from './body-failures.js';
6
6
  import { findEchoMismatches } from './echo-mismatch.js';
@@ -9,6 +9,34 @@ import { asString } from '@reticlehq/core';
9
9
  import { isDeclaredRead, matchesDeclaredFailure } from '../question/declared.js';
10
10
  import { runRegisteredFolds } from './contradiction-folds.js';
11
11
  import { isMeaningfulStateChange } from '../state-bookkeeping.js';
12
+ /** What the state-vs-render rule makes of a window. See `readStateRender`. */
13
+ export const StateRender = {
14
+ CLEAR: 'clear',
15
+ RAISE: 'raise',
16
+ /** No DOM node moved, and a canvas on screen could hold the render in pixels not seen to change. */
17
+ CANVAS_UNOBSERVED: 'canvas-unobserved',
18
+ };
19
+ /**
20
+ * The state-vs-render reading of a window, one function for the rule and for the coverage line that
21
+ * names its abstention, so the two cannot disagree. It fires on an ABSENCE, so it is scoped tightly:
22
+ * only for a window attributed to an ACTION, only when state moved, only when no DOM node, route or
23
+ * app-written field moved with it (`screenMoved`), and only when the window carries no network at
24
+ * all. A request belongs to the rules for failed, ignored and unsettled calls. A canvas that painted
25
+ * is the screen moving (#1525); a canvas whose paint was not seen makes the rule abstain.
26
+ */
27
+ export function readStateRender(events, options) {
28
+ if (options.actionSince === undefined ||
29
+ !events.some(isMeaningfulStateChange) ||
30
+ events.some((e) => e.type === EventType.NET_REQUEST || e.type === EventType.NET_PENDING) ||
31
+ events.some(screenMoved)) {
32
+ return StateRender.CLEAR;
33
+ }
34
+ const paint = canvasPaint(events, options.prior ?? [], options.actionSince);
35
+ if (CanvasPaint.NONE === paint) {
36
+ return StateRender.RAISE;
37
+ }
38
+ return CanvasPaint.UNOBSERVED === paint ? StateRender.CANVAS_UNOBSERVED : StateRender.CLEAR;
39
+ }
12
40
  /**
13
41
  * The contradiction hunter.
14
42
  *
@@ -69,28 +97,29 @@ const SERVER_FAULT_MIN = 500;
69
97
  * one — a false alarm costs a glance, a missed false green ships.
70
98
  */
71
99
  function failureAcknowledged(events) {
72
- // STRUCTURAL first, and language-independent: if the app put the failed call's OWN error text into
73
- // its state, it plainly knows the call failed — whatever language it says so in. The lexical
74
- // patterns below are English-only, so without this a German or Japanese app that surfaces its
75
- // failure perfectly well would be reported as hiding it.
100
+ // STRUCTURAL first, and language-independent: an app that put the failed call's OWN error text or
101
+ // HTTP status into its state knows the call failed (#2173). So does an app that wrote text into
102
+ // an existing alert region after it sent the call. The patterns below are English-only.
76
103
  const errors = events
77
104
  .filter((e) => e.type === EventType.NET_REQUEST && e.data['ok'] !== true)
78
105
  .map((e) => asString(e.data['error']))
79
106
  .filter((text) => text !== undefined && text.length >= MIN_ECHOED_ERROR_LENGTH);
107
+ // Where each event kind carries the text a user would read.
108
+ const ECHO_FIELD = {
109
+ [EventType.STATE_CHANGE]: 'value',
110
+ [EventType.DOM_TEXT]: 'text',
111
+ [EventType.DOM_ADDED]: 'name',
112
+ };
80
113
  const echoesAnError = events.some((e) => {
81
114
  // On screen counts as much as in state: the user reading the server's message is the app
82
115
  // acknowledging the failure, not hiding it (#984).
83
- const value = e.type === EventType.STATE_CHANGE
84
- ? asString(e.data['value'])
85
- : e.type === EventType.DOM_TEXT
86
- ? asString(e.data['text'])
87
- : e.type === EventType.DOM_ADDED
88
- ? asString(e.data['name'])
89
- : undefined;
116
+ const field = ECHO_FIELD[e.type];
117
+ const value = field === undefined ? undefined : asString(e.data[field]);
90
118
  return value !== undefined && errors.some((text) => value.includes(text));
91
119
  });
92
- if (echoesAnError)
120
+ if (echoesAnError || storeEchoesFailedStatus(events) || liveAlertAfterFailedSend(events)) {
93
121
  return true;
122
+ }
94
123
  // So does the accessible way of telling a user something went wrong: an alert appearing, or a
95
124
  // field marked invalid. A rejected write that is the behaviour under test (a 409 on a duplicate
96
125
  // email) is acknowledged exactly this way, and was contradicted for it (#984).
@@ -98,46 +127,39 @@ function failureAcknowledged(events) {
98
127
  (e.type === EventType.DOM_ATTR &&
99
128
  ARIA_INVALID === e.data['attr'] &&
100
129
  'true' === e.data['value']));
101
- if (shownAsError)
130
+ if (shownAsError) {
102
131
  return true;
132
+ }
103
133
  return events.some((e) => {
104
134
  // A failure-shaped SIGNAL is an acknowledgement too. An app that fires `auth:denied` has plainly
105
135
  // not proceeded as if it succeeded, whatever its state paths happen to be named.
106
- if (e.type === EventType.SIGNAL)
136
+ if (e.type === EventType.SIGNAL) {
107
137
  return signalAcknowledgesFailure(asString(e.data['name']) ?? '');
108
- if (e.type !== EventType.STATE_CHANGE)
138
+ }
139
+ if (e.type !== EventType.STATE_CHANGE) {
109
140
  return false;
141
+ }
110
142
  const path = asString(e.data['path']) ?? '';
111
143
  const value = e.data['value'];
112
144
  return ACKNOWLEDGED.test(path) || ('string' === typeof value && ACKNOWLEDGED.test(value));
113
145
  });
114
146
  }
115
147
  const ALERT_ROLE = 'alert';
116
- /** Reticle's own instrumentation's signals (core's `RETICLE_HYDRATION_SIGNAL`); not imported: coupling only shrinks. */
117
- const RETICLE_SIGNAL_NAMESPACE = 'reticle:';
118
148
  const ARIA_INVALID = 'aria-invalid';
119
149
  const MUST_DO_SOMETHING = new Set(['click', 'dblclick', 'submit']);
120
150
  /**
121
- * Whether NOTHING in this window is attributable to the action.
122
- *
123
- * Ambient churn is deliberately not counted as evidence the action worked — a background event
124
- * stream, a polling store, a perf sample and a scroll position all move on their own. What counts:
125
- *
126
- * - a mutation inside the target's own subtree (what the target itself did),
127
- * - a request (the action asked the server for something),
128
- * - a navigation, or a dialog/live region appearing — the two ways a real reaction legitimately
129
- * lands OUTSIDE the target, e.g. a modal portalled to the body.
130
- *
131
- * The last clause is what keeps this from manufacturing noise: a button that opens a modal mutates
132
- * nothing within itself, and must not be called dead.
151
+ * Actions that state ONE intent. Every read issued after one of them comes from that intent, so two
152
+ * reads of one path are a fan-out, not a filter that changed while the first was in flight. Text entry
153
+ * is not here: each keystroke of `type` can issue a read that replaces the last.
133
154
  */
134
- function didNothing(events, requests, mutatedWithin) {
135
- if (mutatedWithin === undefined)
136
- return 0 === events.length;
137
- if (mutatedWithin > 0 || requests.length > 0)
138
- return false;
139
- return !events.some((e) => e.type === EventType.ROUTE_CHANGE || e.type === EventType.VISIBLE_SHOWN);
140
- }
155
+ const ONE_INTENT_ACTIONS = new Set([
156
+ 'click',
157
+ 'dblclick',
158
+ 'select',
159
+ 'check',
160
+ 'uncheck',
161
+ 'submit',
162
+ ]);
141
163
  /**
142
164
  * Was the page HIDDEN at any point in this window?
143
165
  *
@@ -157,25 +179,27 @@ function didNothing(events, requests, mutatedWithin) {
157
179
  function pageWasHidden(events, options) {
158
180
  // The caller states it when it knows. A heartbeat landing inside the window is the fallback, not
159
181
  // the mechanism — see the option doc for why the window alone cannot be trusted to carry one.
160
- if (options.pageHidden !== undefined)
182
+ if (options.pageHidden !== undefined) {
161
183
  return options.pageHidden;
184
+ }
162
185
  return events.some((e) => e.type === EventType.PAGE_HEALTH &&
163
186
  true === e.data?.hidden);
164
187
  }
165
- /** Net-shaped events — the only ones that carry a URL a dev-tooling channel could occupy. */
166
188
  export function findContradictions(allEvents, options = {}) {
167
189
  const all = findWindowContradictions(allEvents, options);
168
190
  // Filtered here rather than inside each rule, so a rule added later inherits the guard by being
169
191
  // classified absence-derived — the one place that already knows which findings rest on silence.
170
192
  // Hiding can only manufacture ABSENCE: a failed request or a contradicting channel is something
171
193
  // that WAS seen, so evidence-derived findings are untouched and still report.
194
+ // A failed read is the exception: hiding cannot make a server return a 5xx.
172
195
  const found = pageWasHidden(allEvents, options)
173
- ? all.filter((c) => !isAbsenceDerived(c.kind))
196
+ ? all.filter((c) => !isAbsenceDerived(c.kind) || c.kind === ContradictionKind.READ_SERVER_FAULT)
174
197
  : all;
175
198
  const predates = allEvents.length > 0 &&
176
199
  allEvents.every((e) => !isSameEditEpoch(e.editEpoch, options.currentEditEpoch));
177
- if (!predates)
200
+ if (!predates) {
178
201
  return found;
202
+ }
179
203
  // Prepended, not appended: the caveat governs how everything under it should be read, and it has
180
204
  // to survive the rules that return early with a single finding of their own.
181
205
  return [
@@ -227,7 +251,10 @@ function findWindowContradictions(allEvents, options) {
227
251
  const settled = events.filter((e) => e.type === EventType.NET_REQUEST).map(netCall);
228
252
  // ── Overlapping reads that settled out of order ─────────────────────────────────────────────
229
253
  // Independent of any action, so it runs on every window: the race is a property of the timeline.
230
- found.push(...findStaleResponses(events));
254
+ // A window that one discrete action opened holds no second intent, so it cannot hold a race.
255
+ found.push(...findStaleResponses(events, {
256
+ oneIntent: floor !== undefined && ONE_INTENT_ACTIONS.has((options.action ?? '').toLowerCase()),
257
+ }));
231
258
  // ── A 2xx whose BODY says it failed ─────────────────────────────────────────────────────────
232
259
  // Needs body capture; silent without it, which is why the assert path also declares when bodies
233
260
  // were never recorded rather than letting an unread payload read as an empty one.
@@ -240,7 +267,9 @@ function findWindowContradictions(allEvents, options) {
240
267
  // Checked first and returned alone: nothing is attributable to the action, so every rule below is
241
268
  // reasoning about someone else's events.
242
269
  const action = (options.action ?? '').toLowerCase();
243
- if (MUST_DO_SOMETHING.has(action) && didNothing(events, settled, options.mutatedWithin)) {
270
+ if (MUST_DO_SOMETHING.has(action) &&
271
+ true !== options.routeProved &&
272
+ didNothing(events, settled, options)) {
244
273
  const measured = options.mutatedWithin !== undefined;
245
274
  return [
246
275
  {
@@ -288,7 +317,7 @@ function findWindowContradictions(allEvents, options) {
288
317
  const advanced = floor === undefined ? undefined : uiAdvanced(events);
289
318
  const signals = events
290
319
  .filter((e) => e.type === EventType.SIGNAL)
291
- .map((e) => asString(e.data['name']) ?? 'signal');
320
+ .map((e) => asString(e.data['name']) ?? UNNAMED_SIGNAL);
292
321
  // ── The route moved and nothing was rendered for it ─────────────────────────────────────────
293
322
  // A navigation that neither fetches nor renders arrived nowhere. Distinct from a dead control:
294
323
  // the control worked, the DESTINATION is empty — which is why every "did the click do something"
@@ -409,10 +438,11 @@ function findWindowContradictions(allEvents, options) {
409
438
  // observation benchmark: one of two false positives across 47 cells, and the argument for it is
410
439
  // the paragraph above, which had simply not been carried down here.
411
440
  const unexpectedWrites = unexpected.filter(isMutating);
412
- if (failedWrites.length > 0 && successSignals.length > 0 && !failureAcknowledged(events)) {
441
+ const claims = successClaims(events, failedWrites, successSignals, options.expectedFailures);
442
+ if (failedWrites.length > 0 && claims.length > 0 && !failureAcknowledged(events)) {
413
443
  found.push({
414
444
  kind: ContradictionKind.SIGNAL_CONTRADICTED,
415
- claim: `the app fired ${successSignals.map((s) => `"${s}"`).join(', ')}`,
445
+ claim: `the app fired ${claims.map((s) => `"${s}"`).join(', ')}`,
416
446
  counter: `${String(failedWrites.length)} write(s) in the same window failed`,
417
447
  detail: failedWrites.map(describe).join('; '),
418
448
  });
@@ -436,11 +466,44 @@ function findWindowContradictions(allEvents, options) {
436
466
  });
437
467
  }
438
468
  }
469
+ // ── A read of the app's own failed with a server error ──────────────────────────────────────
470
+ // The rules above skip a GET because the DOM shows its payload. A 5xx breaks that premise: the
471
+ // page keeps stale or placeholder content, and a route or a label still holds over it. Field
472
+ // report: a replayed flow passed over a 500 and a 502 from the app's own API.
473
+ //
474
+ // `unexpected` already excludes foreign and dev-tooling traffic, traffic before the action, a
475
+ // failure a later retry recovered, and a failure the caller declared. A 4xx is left alone: a 401
476
+ // or a 404 probe is often the intended path. Writes are left to the write rules above.
477
+ //
478
+ // A read that failed the same way BEFORE the action is ambient: a poll or a bootstrap that the
479
+ // action did not cause, and that the screen already lived with. The observation benchmark grades
480
+ // a first-party poll that fails during an action as a false positive. The ceiling: a caller that
481
+ // passes no `prior` (flow replay, through `stepEffect`) reports a poll inside the window. That
482
+ // is `unknown`, not `no`. Replay passes `failedReadsBefore` instead of `prior`: this rule reads
483
+ // it and no other, because `prior` also changes `appIsSilent`, which needs its own measurement.
484
+ const failedBefore = [...(options.prior ?? []), ...(options.failedReadsBefore ?? [])]
485
+ .filter((e) => e.type === EventType.NET_REQUEST)
486
+ .map(netCall)
487
+ .filter((c) => c.status !== undefined && c.status >= SERVER_FAULT_MIN);
488
+ const failedReads = unexpected.filter((c) => !isMutating(c) &&
489
+ c.status !== undefined &&
490
+ c.status >= SERVER_FAULT_MIN &&
491
+ !failedBefore.some((p) => p.method === c.method && p.matchUrl === c.matchUrl));
492
+ if (floor !== undefined && failedReads.length > 0 && !failureAcknowledged(events)) {
493
+ found.push({
494
+ kind: ContradictionKind.READ_SERVER_FAULT,
495
+ claim: 'the page shows what the assertion read',
496
+ counter: `${String(failedReads.length)} read(s) of the app's own in the same window failed with a server error`,
497
+ detail: failedReads.map(describe).join('; '),
498
+ });
499
+ }
439
500
  // ── A write succeeded and nothing on the client moved ───────────────────────────────────────
440
501
  // Writes only: a GET that changes nothing is a prefetch; a POST that changes nothing is a lost
441
502
  // write, a response parsed into the void, or a render that never happened.
442
503
  if (false === advanced) {
443
- const ignoredWrites = settled.filter((c) => true === c.ok && isMutating(c));
504
+ // A write the departed document made is left out: its page unloaded after it, and the unload
505
+ // is the client moving on (#1944).
506
+ const ignoredWrites = settled.filter((c) => true === c.ok && isMutating(c) && true !== c.departed);
444
507
  if (ignoredWrites.length > 0) {
445
508
  // ...unless THIS document handed the consequence to another browsing context. An OAuth sign-in
446
509
  // posts, succeeds, and continues in a popup the in-page SDK cannot follow (#508): the original
@@ -468,27 +531,17 @@ function findWindowContradictions(allEvents, options) {
468
531
  // ── The store committed and the screen never moved ─────────────────────────────────────────
469
532
  //
470
533
  // Scoped as tightly as the one below, and for the same reason: it fires on an ABSENCE, which is
471
- // the easiest way to build a false positive. Only for a window attributed to an ACTION, only when
472
- // state actually moved, only when NO DOM node moved with it, and only when nothing is still in
473
- // flight that the render could legitimately be waiting on.
534
+ // the easiest way to build a false positive. The scoping is in `readStateRender`.
474
535
  //
475
- // Route movement counts as the screen moving: a navigation IS a render, and a store change that
476
- // drives one has been corroborated, and so has a field the app wrote (`screenMoved`).
477
- //
478
- // And only when the window carries NO NETWORK AT ALL. A request means the app reached for
479
- // something, and whether it failed, was ignored or never settled already belongs to three other
480
- // rules — firing here as well would report one fact twice, which is exactly the scoping the
481
- // signal rule below had to earn. Two existing tests proved it: both describe a window with a
482
- // failed call in it, and both were already answered by the rule that owns that fact.
483
- if (options.actionSince !== undefined &&
484
- events.some(isMeaningfulStateChange) &&
485
- !events.some((e) => e.type === EventType.NET_REQUEST || e.type === EventType.NET_PENDING) &&
486
- !events.some(screenMoved)) {
536
+ // A canvas repaint counts as the screen moving (#1525). When a canvas is on screen and no paint on
537
+ // it was seen, the rule does not fire: the render can be in pixels this window could not compare.
538
+ // The act tool names that on its coverage line, so the gap is stated rather than hidden.
539
+ if (StateRender.RAISE === readStateRender(events, options)) {
487
540
  found.push({
488
541
  kind: ContradictionKind.STATE_VS_RENDER,
489
542
  claim: 'the store committed a change',
490
- counter: 'nothing rendered in the same window: no DOM or app-written field change and no route ' +
491
- 'movement, with no request still in flight the render could be waiting on',
543
+ counter: 'nothing rendered in the same window: no DOM, canvas or app-written field change and no ' +
544
+ 'route movement, with no request still in flight the render could be waiting on',
492
545
  detail: 'a component that does not re-render on a committed change shows the OLD value while the ' +
493
546
  'app is internally consistent, which is why nothing else reports it',
494
547
  });
@@ -563,16 +616,20 @@ function findWindowContradictions(allEvents, options) {
563
616
  const navigatedAt = events.find((e) => EventType.ROUTE_CHANGE === e.type && e.t >= actionSince)?.t;
564
617
  const writes = new Map();
565
618
  for (const event of events) {
566
- if (event.type !== EventType.NET_REQUEST || event.t < actionSince)
619
+ if (event.type !== EventType.NET_REQUEST || event.t < actionSince) {
567
620
  continue;
568
- if (navigatedAt !== undefined && event.t >= navigatedAt)
621
+ }
622
+ if (navigatedAt !== undefined && event.t >= navigatedAt) {
569
623
  continue;
624
+ }
570
625
  const call = netCall(event);
571
- if (!isMutating(call))
626
+ if (!isMutating(call)) {
572
627
  continue;
628
+ }
573
629
  // Declared a read by the assertion itself (#1353): a repeat is the app reading twice.
574
- if (isDeclaredRead(call, options.repeatableNetUrls))
630
+ if (isDeclaredRead(call, options.repeatableNetUrls)) {
575
631
  continue;
632
+ }
576
633
  const label = `${call.method} ${call.url}`;
577
634
  const calls = writes.get(label) ?? [];
578
635
  // `landed` is tracked per call rather than counted here, because the claim is about what
@@ -599,8 +656,9 @@ function findWindowContradictions(allEvents, options) {
599
656
  for (const group of groups) {
600
657
  const times = group.map((c) => c.t);
601
658
  const landed = group.filter((c) => c.landed).length;
602
- if (times.length < 2)
659
+ if (times.length < 2) {
603
660
  continue;
661
+ }
604
662
  // The identity also has to say WHICH PAYLOAD, not only which action ran. A group held
605
663
  // together by an action id over bodies the record could not read keeps the uncertainty in
606
664
  // its wording: two runs of one action can carry different form data.
@@ -611,14 +669,16 @@ function findWindowContradictions(allEvents, options) {
611
669
  // failed are not a double submit either — nothing applied even once, so the claim "one user
612
670
  // action was performed" is not contradicted by them. A call with no verdict at all still
613
671
  // counts, because absence of a status is not evidence the write was rejected.
614
- if (landed < 2)
672
+ if (landed < 2) {
615
673
  continue;
674
+ }
616
675
  // A steady cadence is a POLL, and a poll is not a double submit. An app that polls could not
617
676
  // produce a verdict at all: a camera scan loop POSTing until it acquires a lock had every
618
677
  // assertion that had already seen its consequence come back `unknown` behind writes that
619
678
  // were the app working correctly (#673).
620
- if (isSteadyCadence(times))
679
+ if (isSteadyCadence(times)) {
621
680
  continue;
681
+ }
622
682
  // A burst the assertion never mentioned is still worth telling the caller about -- a retry
623
683
  // loop or a bursty beacon is a real finding -- but it is not evidence about the consequence
624
684
  // they declared, so it is reported and decides nothing. The named case keeps its downgrade:
@@ -653,7 +713,10 @@ function findWindowContradictions(allEvents, options) {
653
713
  .map((e) => asString(e.data['id']))
654
714
  .filter((id) => id !== undefined));
655
715
  const inFlight = events
656
- .filter((e) => e.type === EventType.NET_PENDING)
716
+ // A departure never completes by construction (NetInitiator.NAVIGATION): the browser leaves,
717
+ // or turns it into a download and stays. A request whose page unloaded first lost its answer
718
+ // the same way (#1944). The settle oracle reads the same `neverAnswered`; so does this.
719
+ .filter((e) => e.type === EventType.NET_PENDING && !neverAnswered(e.data))
657
720
  .map((e) => ({ id: asString(e.data['id']), call: netCall(e) }))
658
721
  .filter((p) => p.id === undefined || !settledIds.has(p.id));
659
722
  if (inFlight.length > 0) {
@@ -696,30 +759,34 @@ function findWindowContradictions(allEvents, options) {
696
759
  */
697
760
  export function findStalledPagination(events, prior = []) {
698
761
  const moved = events.flatMap((event) => {
699
- if (event.type !== EventType.DOM_TEXT)
762
+ if (event.type !== EventType.DOM_TEXT) {
700
763
  return [];
764
+ }
701
765
  const now = pageNumber(event.data['text']);
702
766
  const before = pageNumber(event.data['old']);
703
767
  return now !== undefined && before !== undefined && now !== before ? [{ before, now }] : [];
704
768
  });
705
769
  const label = moved[0];
706
- if (label === undefined)
770
+ if (label === undefined) {
707
771
  return [];
772
+ }
708
773
  const last = new Map();
709
774
  for (const event of prior) {
710
775
  const request = pageRequest(event);
711
- if (request !== undefined)
776
+ if (request !== undefined) {
712
777
  last.set(request.path, request);
778
+ }
713
779
  }
714
780
  for (const event of events) {
715
781
  const request = pageRequest(event);
716
- if (request === undefined)
782
+ if (request === undefined) {
717
783
  continue;
784
+ }
718
785
  const previous = last.get(request.path);
719
786
  if (previous !== undefined &&
720
787
  previous.param === request.param &&
721
788
  previous.value === request.value &&
722
- previous.query === request.query)
789
+ previous.query === request.query) {
723
790
  return [
724
791
  {
725
792
  kind: ContradictionKind.PAGINATION_NOT_FETCHED,
@@ -728,6 +795,7 @@ export function findStalledPagination(events, prior = []) {
728
795
  detail: `${String(event.data['url'])} — the rows shown are still the earlier page, so everything past it cannot be reached`,
729
796
  },
730
797
  ];
798
+ }
731
799
  last.set(request.path, request);
732
800
  }
733
801
  return [];