@reticlehq/engine 3.10.2 → 3.10.4
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 +4 -0
- package/dist/disagreement/contradiction-evidence.js +3 -3
- package/dist/disagreement/contradictions.js +7 -11
- package/dist/question/predicate/predicate-element.d.ts +1 -0
- package/dist/question/predicate/predicate-element.js +24 -6
- package/dist/write-answer.d.ts +36 -0
- package/dist/write-answer.js +73 -0
- package/package.json +3 -3
|
@@ -321,6 +321,10 @@ export type TargetFate = (typeof TargetFate)[keyof typeof TargetFate];
|
|
|
321
321
|
export declare function targetFate(events: readonly ReticleEvent[], ref: string | undefined, failedAt: number): TargetFate | undefined;
|
|
322
322
|
/** The name a signal is reported under when the app gave it none. */
|
|
323
323
|
export declare const UNNAMED_SIGNAL = "signal";
|
|
324
|
+
/** Whether `a` was emitted before `b`. The sequence number is exact; the clock can tie. */
|
|
325
|
+
export declare function emittedBefore(a: ReticleEvent, b: ReticleEvent): boolean;
|
|
326
|
+
/** The event that recorded when this call was SENT, if the window holds it. */
|
|
327
|
+
export declare function sendOf(events: readonly ReticleEvent[], call: NetCall): ReticleEvent | undefined;
|
|
324
328
|
/**
|
|
325
329
|
* The success signals that can claim the failed writes in this window landed.
|
|
326
330
|
*
|
|
@@ -624,11 +624,11 @@ export function targetFate(events, ref, failedAt) {
|
|
|
624
624
|
export const UNNAMED_SIGNAL = 'signal';
|
|
625
625
|
const nameOf = (e) => asString(e.data['name']) ?? UNNAMED_SIGNAL;
|
|
626
626
|
/** Whether `a` was emitted before `b`. The sequence number is exact; the clock can tie. */
|
|
627
|
-
function emittedBefore(a, b) {
|
|
627
|
+
export function emittedBefore(a, b) {
|
|
628
628
|
return a.seq !== undefined && b.seq !== undefined ? a.seq < b.seq : a.t < b.t;
|
|
629
629
|
}
|
|
630
|
-
/** The event that recorded when this
|
|
631
|
-
function sendOf(events, call) {
|
|
630
|
+
/** The event that recorded when this call was SENT, if the window holds it. */
|
|
631
|
+
export function sendOf(events, call) {
|
|
632
632
|
const answer = events.find((e) => {
|
|
633
633
|
if (e.type !== EventType.NET_REQUEST || e.t !== call.t) {
|
|
634
634
|
return false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { neverAnswered, ContradictionKind, EventType, isAbsenceDerived, isSameDocument, isSameEditEpoch, } from '@reticlehq/core';
|
|
2
2
|
import { describeSuperseded } from '../question/predicate/observed-in-window.js';
|
|
3
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
|
+
import { answersWrites, movesUi } from '../write-answer.js';
|
|
4
5
|
import { findStaleResponses } from './stale-response.js';
|
|
5
6
|
import { findBodyFailures } from './body-failures.js';
|
|
6
7
|
import { findEchoMismatches } from './echo-mismatch.js';
|
|
@@ -49,12 +50,7 @@ export function readStateRender(events, options) {
|
|
|
49
50
|
* Pure: a window of events in, findings out. No session, no IO, no clock.
|
|
50
51
|
*/
|
|
51
52
|
function uiAdvanced(events) {
|
|
52
|
-
return events.some(
|
|
53
|
-
e.type === EventType.DOM_REMOVED ||
|
|
54
|
-
e.type === EventType.DOM_ATTR ||
|
|
55
|
-
e.type === EventType.DOM_TEXT ||
|
|
56
|
-
e.type === EventType.STATE_CHANGE ||
|
|
57
|
-
e.type === EventType.ROUTE_CHANGE);
|
|
53
|
+
return events.some(movesUi);
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
60
56
|
* State paths/values that read as the app recording a failure rather than hiding one.
|
|
@@ -500,11 +496,11 @@ function findWindowContradictions(allEvents, options) {
|
|
|
500
496
|
// ── A write succeeded and nothing on the client moved ───────────────────────────────────────
|
|
501
497
|
// Writes only: a GET that changes nothing is a prefetch; a POST that changes nothing is a lost
|
|
502
498
|
// write, a response parsed into the void, or a render that never happened.
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (ignoredWrites.
|
|
499
|
+
// A write the departed document made is left out: its page unloaded after it, and the unload
|
|
500
|
+
// is the client moving on (#1944).
|
|
501
|
+
const ignoredWrites = settled.filter((c) => true === c.ok && isMutating(c) && true !== c.departed);
|
|
502
|
+
if (advanced !== undefined && ignoredWrites.length > 0) {
|
|
503
|
+
if (!answersWrites(events, ignoredWrites, options.ref)) {
|
|
508
504
|
// ...unless THIS document handed the consequence to another browsing context. An OAuth sign-in
|
|
509
505
|
// posts, succeeds, and continues in a popup the in-page SDK cannot follow (#508): the original
|
|
510
506
|
// tab legitimately never changes, and response-ignored would accuse it of ignoring a response
|
|
@@ -11,6 +11,7 @@ import { type EvalResult } from './predicate-eval.js';
|
|
|
11
11
|
import type { PredicateSession } from './predicate-session.js';
|
|
12
12
|
import { type Baseline, type PropertyAssertion } from './property.js';
|
|
13
13
|
export declare const ARIA_HIDDEN_NOTE = "text is inside an aria-hidden subtree \u2014 drawn on screen but excluded from the accessible tree";
|
|
14
|
+
export declare const ARIA_HIDDEN_STATE_NOTE = "the element is painted on screen but hidden from assistive technology by aria-hidden=\"true\" \u2014 use state: \"painted\" to assert only that it renders";
|
|
14
15
|
/**
|
|
15
16
|
* HTML tag names mapped to the ARIA role that `getRole` gives them. A query like `{ role: "iframe" }`
|
|
16
17
|
* always returns zero results because `iframe` is a tag, not a role. The map names the correct role
|
|
@@ -14,6 +14,7 @@ import { describeCaseMiss, describeSplitTextMiss } from './split-text-miss.js';
|
|
|
14
14
|
import { satisfiesProperty } from './property.js';
|
|
15
15
|
import { describeNameNearMiss } from './name-near-miss.js';
|
|
16
16
|
export const ARIA_HIDDEN_NOTE = 'text is inside an aria-hidden subtree — drawn on screen but excluded from the accessible tree';
|
|
17
|
+
export const ARIA_HIDDEN_STATE_NOTE = 'the element is painted on screen but hidden from assistive technology by aria-hidden="true" — use state: "painted" to assert only that it renders';
|
|
17
18
|
/**
|
|
18
19
|
* HTML tag names mapped to the ARIA role that `getRole` gives them. A query like `{ role: "iframe" }`
|
|
19
20
|
* always returns zero results because `iframe` is a tag, not a role. The map names the correct role
|
|
@@ -260,6 +261,7 @@ const ELEMENT_STATE_SINCE = {
|
|
|
260
261
|
// The key is checked against ElementState by the Record type, so a misspelt state cannot compile.
|
|
261
262
|
pressed: '3.4.0',
|
|
262
263
|
receivesPointer: '3.10.0',
|
|
264
|
+
painted: '3.10.0',
|
|
263
265
|
};
|
|
264
266
|
/** The state, when the page's SDK is older than the first release that answers it. */
|
|
265
267
|
function stateTheSdkPredates(sdk, state) {
|
|
@@ -449,10 +451,11 @@ unlessText) {
|
|
|
449
451
|
if (state !== undefined) {
|
|
450
452
|
const relaxed = await matchOnce(session, query, undefined);
|
|
451
453
|
if (relaxed.matched) {
|
|
454
|
+
const ariaNote = true === match.hint?.ariaHiddenState ? ` — ${ARIA_HIDDEN_STATE_NOTE}` : '';
|
|
452
455
|
return {
|
|
453
456
|
pass: false,
|
|
454
|
-
failureReason: `element matching ${subject} exists${describeRef(relaxed.elements[0])} but not in state '${state}'`,
|
|
455
|
-
observed: `element matching ${subject} is present, states: ${relaxed.elements[0]?.states.join(', ') ?? 'unknown'}`,
|
|
457
|
+
failureReason: `element matching ${subject} exists${describeRef(relaxed.elements[0])} but not in state '${state}'${ariaNote}`,
|
|
458
|
+
observed: `element matching ${subject} is present, states: ${relaxed.elements[0]?.states.join(', ') ?? 'unknown'}${ariaNote}`,
|
|
456
459
|
expected: `element matching ${subject} in state '${state}'`,
|
|
457
460
|
assertion: 'element.state',
|
|
458
461
|
evidence: { nearMiss: relaxed.elements },
|
|
@@ -460,7 +463,10 @@ unlessText) {
|
|
|
460
463
|
}
|
|
461
464
|
}
|
|
462
465
|
if (query.role !== undefined && query.name !== undefined) {
|
|
463
|
-
|
|
466
|
+
// The diagnosis looks where the check looked. A check scoped to one cell must not list the
|
|
467
|
+
// names in every other cell, which can be unrelated user text (#2282).
|
|
468
|
+
const within = scopeOf(query);
|
|
469
|
+
const roleOnly = await matchOnce(session, { role: query.role, ...within }, state);
|
|
464
470
|
if (roleOnly.matched) {
|
|
465
471
|
return {
|
|
466
472
|
pass: false,
|
|
@@ -481,7 +487,7 @@ unlessText) {
|
|
|
481
487
|
// contenteditable composer is not a `textbox`, a styled div is not a `button` — and the name is
|
|
482
488
|
// the part the agent got right. Name the controls carrying it, with their real roles, so the
|
|
483
489
|
// retry targets what exists instead of guessing again. A diagnosis only: `pass` stays false.
|
|
484
|
-
const byName = await nearestByName(session, query.name, state);
|
|
490
|
+
const byName = await nearestByName(session, query.name, state, within);
|
|
485
491
|
if (byName.length > 0) {
|
|
486
492
|
const seen = byName.map((e) => `${'' === e.role ? 'no role' : e.role} "${'' === e.name ? (e.text ?? '') : e.name}" (${e.ref})`);
|
|
487
493
|
return {
|
|
@@ -513,11 +519,13 @@ unlessText) {
|
|
|
513
519
|
const nearMiss = describeNameNearMiss(match.hint?.nameNearMiss, query.name, nearMissRole);
|
|
514
520
|
const caseMiss = describeCaseMiss(match.hint?.caseMiss);
|
|
515
521
|
const ariaNote = true === match.hint?.ariaHiddenMatch ? ARIA_HIDDEN_NOTE : undefined;
|
|
522
|
+
const ariaStateNote = true === match.hint?.ariaHiddenState ? ARIA_HIDDEN_STATE_NOTE : undefined;
|
|
516
523
|
const unreachableRole = describeUnreachableRole(nearMissRole);
|
|
517
524
|
const clause = caseMiss ??
|
|
518
525
|
splitText ??
|
|
519
526
|
nearMiss ??
|
|
520
527
|
ariaNote ??
|
|
528
|
+
ariaStateNote ??
|
|
521
529
|
unreachableRole ??
|
|
522
530
|
(alsoHere === undefined || '' === alsoHere ? undefined : alsoHere);
|
|
523
531
|
const suffix = clause === undefined ? '' : ` — ${clause}`;
|
|
@@ -673,14 +681,24 @@ export function withTextProperty(base, assertion, subject, baseline) {
|
|
|
673
681
|
evidence: described,
|
|
674
682
|
};
|
|
675
683
|
}
|
|
684
|
+
/** The scope of a query, and `self` with it, to carry into a follow-up query. Empty when unscoped. */
|
|
685
|
+
function scopeOf(query) {
|
|
686
|
+
if (query.scope === undefined) {
|
|
687
|
+
return {};
|
|
688
|
+
}
|
|
689
|
+
return { scope: query.scope, ...(true === query.self ? { self: true } : {}) };
|
|
690
|
+
}
|
|
676
691
|
/** How many same-name controls a role miss names. */
|
|
677
692
|
const MAX_BY_NAME = 3;
|
|
678
693
|
/**
|
|
679
694
|
* Elements carrying an accessible name, whatever their role: by label (aria-label, <label>), then by
|
|
680
695
|
* placeholder. The first locator that finds any wins; at most MAX_BY_NAME are named.
|
|
681
696
|
*/
|
|
682
|
-
async function nearestByName(session, name, state) {
|
|
683
|
-
for (const query of [
|
|
697
|
+
async function nearestByName(session, name, state, within) {
|
|
698
|
+
for (const query of [
|
|
699
|
+
{ label: name, ...within },
|
|
700
|
+
{ placeholder: name, ...within },
|
|
701
|
+
]) {
|
|
684
702
|
const found = await matchOnce(session, query, state);
|
|
685
703
|
if (found.matched) {
|
|
686
704
|
return found.elements.slice(0, MAX_BY_NAME);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the client answered a successful write, for `response-ignored` (#2115).
|
|
3
|
+
*
|
|
4
|
+
* Split out of `disagreement/contradiction-evidence.ts`, which is at the line cap. It sits here,
|
|
5
|
+
* next to `state-bookkeeping.ts`, so the `disagreement` folder gets no new public path. It reads the
|
|
6
|
+
* order of events against each write's send, with the helpers that file uses for success claims.
|
|
7
|
+
*/
|
|
8
|
+
import { type ReticleEvent } from '@reticlehq/core';
|
|
9
|
+
import { type NetCall } from './disagreement/contradiction-evidence.js';
|
|
10
|
+
/** A change of the DOM, the store or the route: the client moved. */
|
|
11
|
+
export declare const movesUi: (e: ReticleEvent) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Did the client move in a way that can answer these successful writes?
|
|
14
|
+
*
|
|
15
|
+
* The acted control becoming `disabled` or `aria-busy` after the write was sent cannot answer it
|
|
16
|
+
* (#2115). It is the control saying "wait" while the request runs. It made `uiAdvanced` true, and
|
|
17
|
+
* the rule stood down on an app that ignored its response. A change of those attributes before the
|
|
18
|
+
* send, such as a fill enabling its submit button, is not about the write at all.
|
|
19
|
+
*
|
|
20
|
+
* After the send, every change that takes the control out of its waiting state still counts. The
|
|
21
|
+
* limit is the send and not the answer, because the answer can be recorded after the app's own
|
|
22
|
+
* handler ran: over XHR on `loadend`, after the `load` handler and axios's, and with body capture
|
|
23
|
+
* after the body was read. A settings form that enables Save again in its response handler is
|
|
24
|
+
* correct, because its fields already show the saved values.
|
|
25
|
+
*
|
|
26
|
+
* Two limits, on purpose. A control that only becomes disabled after the answer, with nothing else
|
|
27
|
+
* moving, is reported: the same reading as the waiting state. And a label on the control
|
|
28
|
+
* (`dom.text`, such as "Saving…") still counts wherever it is, because a label can also carry the
|
|
29
|
+
* result, such as a count on a like button.
|
|
30
|
+
*
|
|
31
|
+
* Every other change still counts wherever it is, so an optimistic update is still an answer. The
|
|
32
|
+
* order is the page's own sequence number, because the bridge stamps the time when an event
|
|
33
|
+
* arrives, not when the page made it. When the window cannot say what came first (no acted
|
|
34
|
+
* control, or no send), every change counts, as before.
|
|
35
|
+
*/
|
|
36
|
+
export declare function answersWrites(events: readonly ReticleEvent[], writes: readonly NetCall[], ref: string | undefined): boolean;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the client answered a successful write, for `response-ignored` (#2115).
|
|
3
|
+
*
|
|
4
|
+
* Split out of `disagreement/contradiction-evidence.ts`, which is at the line cap. It sits here,
|
|
5
|
+
* next to `state-bookkeeping.ts`, so the `disagreement` folder gets no new public path. It reads the
|
|
6
|
+
* order of events against each write's send, with the helpers that file uses for success claims.
|
|
7
|
+
*/
|
|
8
|
+
import { EventType, asString } from '@reticlehq/core';
|
|
9
|
+
import { emittedBefore, sendOf } from './disagreement/contradiction-evidence.js';
|
|
10
|
+
/** A change of the DOM, the store or the route: the client moved. */
|
|
11
|
+
export const movesUi = (e) => e.type === EventType.DOM_ADDED ||
|
|
12
|
+
e.type === EventType.DOM_REMOVED ||
|
|
13
|
+
e.type === EventType.DOM_ATTR ||
|
|
14
|
+
e.type === EventType.DOM_TEXT ||
|
|
15
|
+
e.type === EventType.STATE_CHANGE ||
|
|
16
|
+
e.type === EventType.ROUTE_CHANGE;
|
|
17
|
+
/**
|
|
18
|
+
* The attributes a control sets while it waits for its request: `disabled` and `aria-busy`. Neither
|
|
19
|
+
* applies the write, so neither is an optimistic update. The browser observer records `disabled`
|
|
20
|
+
* today and not `aria-busy`; a realm that records it gets the same reading.
|
|
21
|
+
*/
|
|
22
|
+
const DISABLED_ATTR = 'disabled';
|
|
23
|
+
const ARIA_BUSY_ATTR = 'aria-busy';
|
|
24
|
+
/** The `aria-busy` value that marks a control as busy. Any other value, or none, clears it. */
|
|
25
|
+
const ARIA_BUSY_ON = 'true';
|
|
26
|
+
const WAITING_ATTRS = new Set([DISABLED_ATTR, ARIA_BUSY_ATTR]);
|
|
27
|
+
/** Whether this change puts the control into its waiting state, rather than taking it out. */
|
|
28
|
+
function setsWaiting(e) {
|
|
29
|
+
const value = asString(e.data['value']);
|
|
30
|
+
return ARIA_BUSY_ATTR === asString(e.data['attr']) ? ARIA_BUSY_ON === value : value !== undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Did the client move in a way that can answer these successful writes?
|
|
34
|
+
*
|
|
35
|
+
* The acted control becoming `disabled` or `aria-busy` after the write was sent cannot answer it
|
|
36
|
+
* (#2115). It is the control saying "wait" while the request runs. It made `uiAdvanced` true, and
|
|
37
|
+
* the rule stood down on an app that ignored its response. A change of those attributes before the
|
|
38
|
+
* send, such as a fill enabling its submit button, is not about the write at all.
|
|
39
|
+
*
|
|
40
|
+
* After the send, every change that takes the control out of its waiting state still counts. The
|
|
41
|
+
* limit is the send and not the answer, because the answer can be recorded after the app's own
|
|
42
|
+
* handler ran: over XHR on `loadend`, after the `load` handler and axios's, and with body capture
|
|
43
|
+
* after the body was read. A settings form that enables Save again in its response handler is
|
|
44
|
+
* correct, because its fields already show the saved values.
|
|
45
|
+
*
|
|
46
|
+
* Two limits, on purpose. A control that only becomes disabled after the answer, with nothing else
|
|
47
|
+
* moving, is reported: the same reading as the waiting state. And a label on the control
|
|
48
|
+
* (`dom.text`, such as "Saving…") still counts wherever it is, because a label can also carry the
|
|
49
|
+
* result, such as a count on a like button.
|
|
50
|
+
*
|
|
51
|
+
* Every other change still counts wherever it is, so an optimistic update is still an answer. The
|
|
52
|
+
* order is the page's own sequence number, because the bridge stamps the time when an event
|
|
53
|
+
* arrives, not when the page made it. When the window cannot say what came first (no acted
|
|
54
|
+
* control, or no send), every change counts, as before.
|
|
55
|
+
*/
|
|
56
|
+
export function answersWrites(events, writes, ref) {
|
|
57
|
+
if (ref === undefined) {
|
|
58
|
+
return events.some(movesUi);
|
|
59
|
+
}
|
|
60
|
+
const sends = [];
|
|
61
|
+
for (const call of writes) {
|
|
62
|
+
const send = sendOf(events, call);
|
|
63
|
+
if (send === undefined) {
|
|
64
|
+
return events.some(movesUi);
|
|
65
|
+
}
|
|
66
|
+
sends.push(send);
|
|
67
|
+
}
|
|
68
|
+
const waiting = (e) => e.type === EventType.DOM_ATTR &&
|
|
69
|
+
e.ref === ref &&
|
|
70
|
+
WAITING_ATTRS.has(asString(e.data['attr']) ?? '') &&
|
|
71
|
+
(sends.every((send) => emittedBefore(e, send)) || setsWaiting(e));
|
|
72
|
+
return events.some((e) => movesUi(e) && !waiting(e));
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/engine",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.4",
|
|
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,8 +57,8 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"zod": "^4.6.6",
|
|
60
|
-
"@reticlehq/core": "3.10.
|
|
61
|
-
"open-verification": "1.
|
|
60
|
+
"@reticlehq/core": "3.10.4",
|
|
61
|
+
"open-verification": "1.2.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsc -b && node ../scripts/alias-dist.mjs",
|