@reticlehq/engine 3.10.11 → 3.11.1
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/bounded-list.d.ts +41 -0
- package/dist/bounded-list.js +82 -0
- package/dist/disagreement/contradiction-evidence.d.ts +4 -30
- package/dist/disagreement/contradiction-evidence.js +23 -30
- package/dist/disagreement/contradiction-types.d.ts +14 -4
- package/dist/disagreement/contradictions.js +34 -7
- package/dist/disagreement/unit-mismatch.js +1 -1
- package/dist/evidence/blind-spots.d.ts +13 -5
- package/dist/evidence/blind-spots.js +88 -8
- package/dist/evidence/instrumentation-gaps.d.ts +6 -0
- package/dist/evidence/instrumentation-gaps.js +4 -3
- package/dist/evidence/unsettled.js +13 -4
- package/dist/question/declared.d.ts +20 -6
- package/dist/question/declared.js +31 -12
- package/dist/question/predicate/net-blind-spots.d.ts +7 -0
- package/dist/question/predicate/net-blind-spots.js +15 -0
- package/dist/question/predicate/predicate-element.d.ts +3 -1
- package/dist/question/predicate/predicate-element.js +104 -16
- package/dist/question/predicate/predicate-eval-kit.d.ts +26 -0
- package/dist/question/predicate/predicate-eval-kit.js +29 -0
- package/dist/question/predicate/predicate-eval.js +13 -3
- package/dist/question/predicate/predicate.js +38 -30
- package/dist/window/event-filters.d.ts +3 -1
- package/dist/window/event-filters.js +6 -2
- package/dist/write-identity.d.ts +36 -0
- package/dist/write-identity.js +31 -0
- package/package.json +3 -3
|
@@ -10,6 +10,7 @@ import { PredicateSchema, evalNet, evalConsole, evalSignal, evalSettled, } from
|
|
|
10
10
|
import { evalAnimationPredicate } from './predicate-animation.js';
|
|
11
11
|
export { PredicateSchema, PredicateKind };
|
|
12
12
|
import { withinBudget } from './predicate-session.js';
|
|
13
|
+
import { ELEMENT_STATE_ASSERTION, unansweredRead, withoutReadError } from './predicate-eval-kit.js';
|
|
13
14
|
const ANIMATION_RUNTIME = {
|
|
14
15
|
startEventType: EventType.ANIM_START,
|
|
15
16
|
endEventType: EventType.ANIM_END,
|
|
@@ -24,9 +25,12 @@ const ANIMATION_RUNTIME = {
|
|
|
24
25
|
* nothing was proven; what changes is that the verdict reads UNKNOWN rather than blaming the app for
|
|
25
26
|
* a clause the CALL under-specified.
|
|
26
27
|
*/
|
|
27
|
-
function unreadableComposite(child, evidence) {
|
|
28
|
+
function unreadableComposite(child, evidence, clauses) {
|
|
28
29
|
const reason = child.inconclusive ?? 'a sub-predicate could not be evaluated';
|
|
29
|
-
|
|
30
|
+
// Kept so the wait and the pre-check can act on a read that threw. See `EvalResult.readError`.
|
|
31
|
+
const readError = clauses.find((r) => r.readError !== undefined)?.readError;
|
|
32
|
+
const thrown = readError === undefined ? {} : { readError };
|
|
33
|
+
return { pass: false, failureReason: reason, inconclusive: reason, evidence, ...thrown };
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Oracles whose ONLY source of truth is the event window.
|
|
@@ -132,7 +136,7 @@ function evidenceProvesPageRendered(result) {
|
|
|
132
136
|
if ('splitText' in evidence || 'caseMiss' in evidence) {
|
|
133
137
|
return true;
|
|
134
138
|
}
|
|
135
|
-
if ('nearMiss' in evidence &&
|
|
139
|
+
if ('nearMiss' in evidence && ELEMENT_STATE_ASSERTION === result.assertion) {
|
|
136
140
|
return true;
|
|
137
141
|
}
|
|
138
142
|
return false;
|
|
@@ -278,6 +282,17 @@ function failureRestsOnSeeing(predicate) {
|
|
|
278
282
|
// `count: 0` is absence written as arithmetic, and fails the same way: by matching something.
|
|
279
283
|
return 'count' in predicate && 0 === predicate.count;
|
|
280
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Each clause of an `allOf` or `anyOf`, read on its own.
|
|
287
|
+
*
|
|
288
|
+
* A clause whose read throws gives the same result that the wait gives a lone predicate that
|
|
289
|
+
* throws: inconclusive, with the reason kept. With `Promise.all`, one throw rejected the whole
|
|
290
|
+
* composite. The other clauses' answers were lost, and the wait graded all of it unknown (#1656).
|
|
291
|
+
* Now the composite's own rules decide: a clause that failed outranks one nobody could read.
|
|
292
|
+
*/
|
|
293
|
+
function evaluateClauses(session, clauses, since, diagnose, baselines) {
|
|
294
|
+
return Promise.all(clauses.map((p) => evaluatePredicate(session, p, since, diagnose, baselines).catch(unansweredRead)));
|
|
295
|
+
}
|
|
281
296
|
export async function evaluatePredicate(session, predicate, since = 0, diagnose = true,
|
|
282
297
|
/**
|
|
283
298
|
* The readings taken BEFORE the action, keyed by the leaf that asked for one.
|
|
@@ -393,7 +408,7 @@ diagnose = true, baselines) {
|
|
|
393
408
|
case PredicateKind.COMPARE:
|
|
394
409
|
return evalCompare(session, events, predicate, diagnose);
|
|
395
410
|
case PredicateKind.ALL_OF: {
|
|
396
|
-
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await
|
|
411
|
+
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await evaluateClauses(session, predicate.predicates, since, diagnose, baselines));
|
|
397
412
|
// A clause that genuinely failed OUTRANKS one nobody could read. Softening a real failure to
|
|
398
413
|
// UNKNOWN would hide the defect the agent came for, which is the more expensive of the two
|
|
399
414
|
// mistakes; the reverse — grading an unreadable clause as a defect in the app — is the one
|
|
@@ -408,17 +423,17 @@ diagnose = true, baselines) {
|
|
|
408
423
|
pass: false,
|
|
409
424
|
failureReason: failed.failureReason ?? 'a sub-predicate of allOf failed',
|
|
410
425
|
...(anyDecided ? { decided: true } : {}),
|
|
411
|
-
evidence: results,
|
|
426
|
+
evidence: results.map(withoutReadError),
|
|
412
427
|
};
|
|
413
428
|
}
|
|
414
429
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
415
430
|
if (unreadable !== undefined) {
|
|
416
|
-
return unreadableComposite(unreadable, results);
|
|
431
|
+
return unreadableComposite(unreadable, results.map(withoutReadError), results);
|
|
417
432
|
}
|
|
418
433
|
return { pass: true, evidence: results.map((r) => r.evidence) };
|
|
419
434
|
}
|
|
420
435
|
case PredicateKind.ANY_OF: {
|
|
421
|
-
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await
|
|
436
|
+
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await evaluateClauses(session, predicate.predicates, since, diagnose, baselines));
|
|
422
437
|
const passed = results.find((r) => r.pass);
|
|
423
438
|
if (passed !== undefined) {
|
|
424
439
|
return { pass: true, evidence: passed.evidence };
|
|
@@ -427,7 +442,7 @@ diagnose = true, baselines) {
|
|
|
427
442
|
// never read: the unreadable clause might have been the one that would have matched.
|
|
428
443
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
429
444
|
if (unreadable !== undefined) {
|
|
430
|
-
return unreadableComposite(unreadable, results);
|
|
445
|
+
return unreadableComposite(unreadable, results.map(withoutReadError), results);
|
|
431
446
|
}
|
|
432
447
|
// A disjunction is decided when EVERY clause is permanently false: no branch can
|
|
433
448
|
// ever become true, so waiting out the budget buys nothing. By this point every
|
|
@@ -437,7 +452,7 @@ diagnose = true, baselines) {
|
|
|
437
452
|
pass: false,
|
|
438
453
|
failureReason: 'no sub-predicate of anyOf matched',
|
|
439
454
|
...(allDecided ? { decided: true } : {}),
|
|
440
|
-
evidence: results,
|
|
455
|
+
evidence: results.map(withoutReadError),
|
|
441
456
|
};
|
|
442
457
|
}
|
|
443
458
|
case PredicateKind.NOT: {
|
|
@@ -447,7 +462,7 @@ diagnose = true, baselines) {
|
|
|
447
462
|
// nobody could evaluate became a verdict of verified, manufactured out of a missing reading.
|
|
448
463
|
// You cannot negate an answer nobody had.
|
|
449
464
|
if (inner.inconclusive !== undefined) {
|
|
450
|
-
return unreadableComposite(inner, inner);
|
|
465
|
+
return unreadableComposite(inner, withoutReadError(inner), [inner]);
|
|
451
466
|
}
|
|
452
467
|
return negate(predicate.predicate, inner);
|
|
453
468
|
}
|
|
@@ -555,18 +570,6 @@ baselines) {
|
|
|
555
570
|
// Released in `finish`, on every exit path. Without it a flood inside the window can evict the
|
|
556
571
|
// event the predicate is armed on, and the verdict blames the app (#668).
|
|
557
572
|
const releaseWindow = session.protectWindow?.(since);
|
|
558
|
-
// A read that threw never looked at the app: the page did not answer, or went away. That is
|
|
559
|
-
// "could not tell", not "looked and it was false", so it is inconclusive, which the verdict rule
|
|
560
|
-
// turns into unknown. As a plain false it was graded assertion_failed: a command timeout on a
|
|
561
|
-
// live, throttled tab came back verified:no against a page that was never read.
|
|
562
|
-
const failed = (error) => {
|
|
563
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
564
|
-
return {
|
|
565
|
-
pass: false,
|
|
566
|
-
failureReason: reason,
|
|
567
|
-
inconclusive: `the page did not answer: ${reason}`,
|
|
568
|
-
};
|
|
569
|
-
};
|
|
570
573
|
let cooldownTimer;
|
|
571
574
|
/** One-shot re-check timed to when a time-based predicate could first pass. See retryAfterMs. */
|
|
572
575
|
let hintTimer;
|
|
@@ -583,7 +586,7 @@ baselines) {
|
|
|
583
586
|
error: error instanceof Error ? error.message : String(error),
|
|
584
587
|
});
|
|
585
588
|
finish({
|
|
586
|
-
...
|
|
589
|
+
...unansweredRead(error),
|
|
587
590
|
failureReason: 'the wait could not be evaluated and was ended rather than left pending: ' +
|
|
588
591
|
(error instanceof Error ? error.message : String(error)),
|
|
589
592
|
});
|
|
@@ -607,7 +610,7 @@ baselines) {
|
|
|
607
610
|
if (confirmTimer !== undefined) {
|
|
608
611
|
clearTimeout(confirmTimer);
|
|
609
612
|
}
|
|
610
|
-
resolve(result);
|
|
613
|
+
resolve(withoutReadError(result));
|
|
611
614
|
};
|
|
612
615
|
// Coalesce re-checks: at most ONE evaluatePredicate is ever in flight (each can be a browser
|
|
613
616
|
// MATCH/STATE_READ round-trip). Events that arrive while one is running set a single trailing
|
|
@@ -644,6 +647,11 @@ baselines) {
|
|
|
644
647
|
finish(r);
|
|
645
648
|
return;
|
|
646
649
|
}
|
|
650
|
+
// Unknown because a read threw: end now, as a lone read that throws does (#1656).
|
|
651
|
+
if (r.readError !== undefined) {
|
|
652
|
+
finish(r);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
647
655
|
// A time-based failure knows when it could stop being one — re-check THEN rather than on
|
|
648
656
|
// the next blind tick. Without this, every `settled` wait paid up to a full poll interval
|
|
649
657
|
// of dead time after the quiet window had already closed: measured at 566–627ms across
|
|
@@ -671,7 +679,7 @@ baselines) {
|
|
|
671
679
|
void evaluatePredicate(reader, predicate, since, true, baselines)
|
|
672
680
|
.then(finish)
|
|
673
681
|
.catch((error) => {
|
|
674
|
-
finish(
|
|
682
|
+
finish(unansweredRead(error));
|
|
675
683
|
});
|
|
676
684
|
};
|
|
677
685
|
if (!holdsForAbsence) {
|
|
@@ -697,7 +705,7 @@ baselines) {
|
|
|
697
705
|
confirmTimer = setTimeout(holdUntilQuiet, ABSENCE_HOLD_MS);
|
|
698
706
|
})
|
|
699
707
|
.catch((error) => {
|
|
700
|
-
finish(
|
|
708
|
+
finish(unansweredRead(error));
|
|
701
709
|
})
|
|
702
710
|
.finally(() => {
|
|
703
711
|
inFlight = false;
|
|
@@ -786,7 +794,7 @@ baselines) {
|
|
|
786
794
|
}));
|
|
787
795
|
})
|
|
788
796
|
.catch((error) => {
|
|
789
|
-
finish(
|
|
797
|
+
finish(unansweredRead(error));
|
|
790
798
|
});
|
|
791
799
|
}, timeoutMs);
|
|
792
800
|
check();
|
|
@@ -810,9 +818,9 @@ export async function provenExpectedLinks(session, predicate, since = 0) {
|
|
|
810
818
|
return per.flat();
|
|
811
819
|
}
|
|
812
820
|
if (PredicateKind.ANY_OF === predicate.kind) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
821
|
+
// Read like the anyOf itself (#1656): a branch whose read throws did not prove its link.
|
|
822
|
+
const read = await evaluateClauses(session, predicate.predicates, since, true, undefined);
|
|
823
|
+
const per = await Promise.all(predicate.predicates.map(async (p, i) => true === read[i]?.pass ? provenExpectedLinks(session, p, since) : []));
|
|
816
824
|
return per.flat();
|
|
817
825
|
}
|
|
818
826
|
return predicateToExpectedLinks(predicate);
|
|
@@ -179,7 +179,9 @@ export interface DeclinedDialog {
|
|
|
179
179
|
* The first dialog in the window that Reticle answered on the app's behalf, or undefined.
|
|
180
180
|
*
|
|
181
181
|
* Only a dialog that carries `answered` counts. An `alert` has no answer, so it cannot change which
|
|
182
|
-
* path the app took.
|
|
182
|
+
* path the app took. A `confirm` answered `true` is not declined: the caller's own
|
|
183
|
+
* `confirmDangerous` said yes to it (#2167), so the app took the path the caller asked for. The SDK
|
|
184
|
+
* and the leased-tab pool both record the answer in this one event.
|
|
183
185
|
*/
|
|
184
186
|
export declare function declinedDialogIn(events: readonly ReticleEvent[]): DeclinedDialog | undefined;
|
|
185
187
|
export {};
|
|
@@ -328,10 +328,14 @@ export function mediaEntryBeforeWindow(events, since, method, urlContains) {
|
|
|
328
328
|
* The first dialog in the window that Reticle answered on the app's behalf, or undefined.
|
|
329
329
|
*
|
|
330
330
|
* Only a dialog that carries `answered` counts. An `alert` has no answer, so it cannot change which
|
|
331
|
-
* path the app took.
|
|
331
|
+
* path the app took. A `confirm` answered `true` is not declined: the caller's own
|
|
332
|
+
* `confirmDangerous` said yes to it (#2167), so the app took the path the caller asked for. The SDK
|
|
333
|
+
* and the leased-tab pool both record the answer in this one event.
|
|
332
334
|
*/
|
|
333
335
|
export function declinedDialogIn(events) {
|
|
334
|
-
const dialog = events.find((e) => e.type === EventType.DIALOG_OPENED &&
|
|
336
|
+
const dialog = events.find((e) => e.type === EventType.DIALOG_OPENED &&
|
|
337
|
+
Object.hasOwn(e.data, 'answered') &&
|
|
338
|
+
true !== e.data['answered']);
|
|
335
339
|
if (dialog === undefined) {
|
|
336
340
|
return undefined;
|
|
337
341
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request CARRIED, as far as the record knows, and which calls carried the same thing.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `disagreement/contradiction-evidence.ts`, which is at the line cap. It sits here,
|
|
5
|
+
* next to `write-answer.ts`, so the `disagreement` folder gets no new public path. The file it
|
|
6
|
+
* left re-exports the three names, so the published import path does not move.
|
|
7
|
+
*/
|
|
8
|
+
import { type ReticleEvent } from '@reticlehq/core';
|
|
9
|
+
/**
|
|
10
|
+
* What this request CARRIED, as far as the record knows — `undefined` when it does not know.
|
|
11
|
+
*
|
|
12
|
+
* The page's shape fingerprint first: it is present on every request from an instrumented page,
|
|
13
|
+
* including the overwhelming majority where body capture is off. A captured body is the fallback for
|
|
14
|
+
* a realm that records one without a fingerprint (desktop IPC). Neither means the record does not
|
|
15
|
+
* say what this request carried — a body the page could not read as text, or an SDK too old to
|
|
16
|
+
* compute a fingerprint — and that is an ABSENCE of identity, not an identity shared with every
|
|
17
|
+
* other silent request.
|
|
18
|
+
*
|
|
19
|
+
* A Server Action's action id joins both halves, and it is the half that survives a `FormData`
|
|
20
|
+
* body: several actions POST to the page's own URL, so without it every call is an unknown identity
|
|
21
|
+
* pooled with all the others, and no fingerprint can separate two that share a shape. The id alone
|
|
22
|
+
* SPLITS two different actions; it cannot say that two runs of one action carried the same thing,
|
|
23
|
+
* and `carried` keeps that limit on the record for the finding to say.
|
|
24
|
+
*/
|
|
25
|
+
export interface WriteIdentity {
|
|
26
|
+
/** The value the grouping compares. */
|
|
27
|
+
readonly key: string;
|
|
28
|
+
/** Whether the key also describes WHAT the request carried, not only which action ran. */
|
|
29
|
+
readonly carried: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function identityOf(event: ReticleEvent): WriteIdentity | undefined;
|
|
32
|
+
/** Split calls to one endpoint into the sets that sent the same thing. Callers check first that
|
|
33
|
+
* every identity is known; an unknown one would otherwise pool with every other unknown. */
|
|
34
|
+
export declare function groupByIdentity<T extends {
|
|
35
|
+
identity: WriteIdentity | undefined;
|
|
36
|
+
}>(calls: readonly T[]): T[][];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request CARRIED, as far as the record knows, and which calls carried the same thing.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `disagreement/contradiction-evidence.ts`, which is at the line cap. It sits here,
|
|
5
|
+
* next to `write-answer.ts`, so the `disagreement` folder gets no new public path. The file it
|
|
6
|
+
* left re-exports the three names, so the published import path does not move.
|
|
7
|
+
*/
|
|
8
|
+
import { NEXT_ACTION_FIELD, REQUEST_SHAPE_FIELD, asString, } from '@reticlehq/core';
|
|
9
|
+
const nonEmpty = (text) => text === undefined || 0 === text.length ? undefined : text;
|
|
10
|
+
export function identityOf(event) {
|
|
11
|
+
const action = asString(event.data[NEXT_ACTION_FIELD]);
|
|
12
|
+
const shape = asString(event.data[REQUEST_SHAPE_FIELD]);
|
|
13
|
+
const body = asString(event.data['requestBody']);
|
|
14
|
+
const carried = nonEmpty(shape) ?? nonEmpty(body);
|
|
15
|
+
if (action === undefined || 0 === action.length) {
|
|
16
|
+
return carried === undefined ? undefined : { key: carried, carried: true };
|
|
17
|
+
}
|
|
18
|
+
return carried === undefined
|
|
19
|
+
? { key: action, carried: false }
|
|
20
|
+
: { key: `${action}:${carried}`, carried: true };
|
|
21
|
+
}
|
|
22
|
+
/** Split calls to one endpoint into the sets that sent the same thing. Callers check first that
|
|
23
|
+
* every identity is known; an unknown one would otherwise pool with every other unknown. */
|
|
24
|
+
export function groupByIdentity(calls) {
|
|
25
|
+
const byIdentity = new Map();
|
|
26
|
+
for (const call of calls) {
|
|
27
|
+
const key = call.identity?.key ?? '';
|
|
28
|
+
byIdentity.set(key, [...(byIdentity.get(key) ?? []), call]);
|
|
29
|
+
}
|
|
30
|
+
return [...byIdentity.values()];
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
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
|
-
"
|
|
61
|
-
"
|
|
60
|
+
"open-verification": "1.2.0",
|
|
61
|
+
"@reticlehq/core": "3.11.1"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsc -b && node ../scripts/alias-dist.mjs",
|