@reticlehq/engine 3.5.0 → 3.6.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 +2 -1
- package/dist/disagreement/contradiction-evidence.d.ts +7 -0
- package/dist/disagreement/contradiction-evidence.js +13 -4
- package/dist/disagreement/contradictions.d.ts +5 -1
- package/dist/disagreement/contradictions.js +109 -3
- package/dist/disagreement/echo-mismatch.js +42 -3
- package/dist/disagreement/reconcile.js +15 -0
- package/dist/disagreement/stale-response.js +32 -2
- package/dist/evidence/accepted-write.d.ts +26 -2
- package/dist/evidence/accepted-write.js +35 -18
- package/dist/evidence/already-true.d.ts +11 -0
- package/dist/evidence/already-true.js +27 -0
- package/dist/evidence/body-capture-remedy.d.ts +10 -0
- package/dist/evidence/body-capture-remedy.js +15 -2
- package/dist/evidence/verified.d.ts +2 -0
- package/dist/evidence/verified.js +10 -0
- package/dist/question/declared.d.ts +4 -4
- package/dist/question/declared.js +6 -4
- package/dist/question/predicate/name-near-miss.d.ts +24 -0
- package/dist/question/predicate/name-near-miss.js +39 -0
- package/dist/question/predicate/predicate-compare.js +13 -4
- package/dist/question/predicate/predicate-element.d.ts +1 -1
- package/dist/question/predicate/predicate-element.js +33 -3
- package/dist/question/predicate/predicate-eval.d.ts +16 -1
- package/dist/question/predicate/predicate-eval.js +70 -13
- package/dist/question/predicate/predicate-parse.js +119 -13
- package/dist/question/predicate/predicate-schema.js +58 -23
- package/dist/question/predicate/predicate-session.d.ts +10 -0
- package/dist/question/predicate/predicate-to-links.js +1 -0
- package/dist/question/predicate/predicate.js +72 -15
- package/dist/question/reaction.d.ts +1 -1
- package/dist/question/reaction.js +1 -1
- package/package.json +2 -2
|
@@ -23,6 +23,7 @@ export function predicateToExpectedLinks(predicate) {
|
|
|
23
23
|
kind: ConsequenceKind.NET,
|
|
24
24
|
urlContains: predicate.urlContains,
|
|
25
25
|
...(predicate.status === undefined ? {} : { status: predicate.status }),
|
|
26
|
+
...(predicate.method === undefined ? {} : { method: predicate.method }),
|
|
26
27
|
},
|
|
27
28
|
];
|
|
28
29
|
case PredicateKind.STATE: {
|
|
@@ -71,22 +71,36 @@ function annotateThrottledMiss(session, predicate, result) {
|
|
|
71
71
|
return result;
|
|
72
72
|
if (failureRestsOnSeeing(predicate))
|
|
73
73
|
return result;
|
|
74
|
-
if (
|
|
74
|
+
if (evidenceProvesPageRendered(result))
|
|
75
75
|
return result;
|
|
76
76
|
return { ...result, inconclusive: THROTTLED_STARVED_NOTE };
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* Did the miss come with proof that the page rendered
|
|
79
|
+
* Did the miss come with proof that the page rendered?
|
|
80
80
|
*
|
|
81
|
-
* The starved-tab caveat is for a page that may not have painted.
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
81
|
+
* The starved-tab caveat is for a page that may not have painted. Evidence that the page IS alive
|
|
82
|
+
* means the miss is real, not an artefact of throttling.
|
|
83
|
+
*
|
|
84
|
+
* - `splitText`: the browser found the requested string in the rendered page, split across
|
|
85
|
+
* children. Target-specific — the text IS the thing that was asked for.
|
|
86
|
+
* - `nearMiss` from `element.state`: the target element exists but in the wrong state. The DOM
|
|
87
|
+
* painted the element itself, so starvation is not the explanation.
|
|
88
|
+
*
|
|
89
|
+
* Excluded:
|
|
90
|
+
* - `nearMiss` from `element.role+name`: a role-only match on a partially rendered page does not
|
|
91
|
+
* prove the named target rendered. The same role may come from a static shell.
|
|
92
|
+
* - `presentTestids`: testids can come from a static shell or another part of a partially rendered
|
|
93
|
+
* page while the requested target remains starved.
|
|
86
94
|
*/
|
|
87
|
-
function
|
|
95
|
+
function evidenceProvesPageRendered(result) {
|
|
88
96
|
const evidence = result.evidence;
|
|
89
|
-
|
|
97
|
+
if ('object' !== typeof evidence || null === evidence)
|
|
98
|
+
return false;
|
|
99
|
+
if ('splitText' in evidence)
|
|
100
|
+
return true;
|
|
101
|
+
if ('nearMiss' in evidence && 'element.state' === result.assertion)
|
|
102
|
+
return true;
|
|
103
|
+
return false;
|
|
90
104
|
}
|
|
91
105
|
/**
|
|
92
106
|
* Has this predicate's failure ALREADY been adjudicated, one level down?
|
|
@@ -272,7 +286,12 @@ diagnose = true, baselines) {
|
|
|
272
286
|
// heuristic, never causation, so a chat message arriving mid-window must not hold settle open.
|
|
273
287
|
const counts = session.ambientCounts?.();
|
|
274
288
|
const settleEvents = counts === undefined ? events : events.filter((e) => !isAmbient(counts, ambientKeyOf(e)));
|
|
275
|
-
|
|
289
|
+
// The same two facts the act settle-wait reads, so `settled` and `act_and_wait`'s own wait stop
|
|
290
|
+
// disagreeing about what is in flight — see `SettleScope`.
|
|
291
|
+
return evalSettled(settleEvents, predicate, session.elapsed(), {
|
|
292
|
+
appUrl: session.url,
|
|
293
|
+
background: session.background,
|
|
294
|
+
});
|
|
276
295
|
}
|
|
277
296
|
case PredicateKind.COMPARE:
|
|
278
297
|
return evalCompare(session, events, predicate, diagnose);
|
|
@@ -367,6 +386,23 @@ const MIN_RECHECK_GAP_MS = 25;
|
|
|
367
386
|
* assertion that latency, so this trades an unbounded false green for a bounded one and says so.
|
|
368
387
|
*/
|
|
369
388
|
const COUNT_CONFIRM_MS = 300;
|
|
389
|
+
/**
|
|
390
|
+
* The least time an absence claim keeps watching after it first reads true, before the page's
|
|
391
|
+
* settle is consulted.
|
|
392
|
+
*
|
|
393
|
+
* An absence is not a count: the thing it rules out is usually a reaction the action scheduled, such
|
|
394
|
+
* as a `setTimeout(() => console.error(...), 800)` in a click handler. Held for COUNT_CONFIRM_MS, that
|
|
395
|
+
* step passed and the error landed in nobody's window (#1344). So an absence holds for this floor
|
|
396
|
+
* AND until the page has gone quiet by the `settled` oracle's own rule, whichever ends later, and the
|
|
397
|
+
* caller's budget still ends both.
|
|
398
|
+
*
|
|
399
|
+
* It is a ceiling, not a proof: an error scheduled more than a second after an otherwise silent
|
|
400
|
+
* action still passes. Nothing on the page says a timer is pending, so a longer floor is the only
|
|
401
|
+
* way to see further, and every live absence check would pay it.
|
|
402
|
+
*/
|
|
403
|
+
const ABSENCE_HOLD_MS = 1_000;
|
|
404
|
+
/** "Has the page gone quiet", asked of the same window the absence is about. */
|
|
405
|
+
const SETTLED_PROBE = { kind: PredicateKind.SETTLED };
|
|
370
406
|
/**
|
|
371
407
|
* Does this predicate assert an exact cardinality anywhere inside it?
|
|
372
408
|
*
|
|
@@ -393,7 +429,7 @@ function assertsExactCount(predicate) {
|
|
|
393
429
|
* Such a claim is about the END of a window for the same reason an exact count is, and reads true
|
|
394
430
|
* at the start of every window by construction. Settled on its first reading, a clean-console check
|
|
395
431
|
* passed on a page whose `console.error` landed a few milliseconds later, which the bench measured
|
|
396
|
-
* once the page ran slower. It holds
|
|
432
|
+
* once the page ran slower. It holds until the page goes quiet; see ABSENCE_HOLD_MS.
|
|
397
433
|
*/
|
|
398
434
|
function claimsAbsence(predicate) {
|
|
399
435
|
if (PredicateKind.NOT === predicate.kind)
|
|
@@ -434,8 +470,9 @@ baselines) {
|
|
|
434
470
|
/** One-shot re-check timed to when a time-based predicate could first pass. See retryAfterMs. */
|
|
435
471
|
let hintTimer;
|
|
436
472
|
// An exact count or an absence keeps watching after it first reads true — see COUNT_CONFIRM_MS
|
|
437
|
-
// and
|
|
438
|
-
const
|
|
473
|
+
// and ABSENCE_HOLD_MS.
|
|
474
|
+
const holdsForAbsence = claimsAbsence(predicate);
|
|
475
|
+
const holdsForCount = assertsExactCount(predicate) || holdsForAbsence;
|
|
439
476
|
let confirming = false;
|
|
440
477
|
let confirmTimer;
|
|
441
478
|
/** Report a wait that could not run, and END it — see guardedCheck. */
|
|
@@ -523,13 +560,33 @@ baselines) {
|
|
|
523
560
|
if (confirming)
|
|
524
561
|
return;
|
|
525
562
|
confirming = true;
|
|
526
|
-
|
|
563
|
+
const confirm = () => {
|
|
527
564
|
void evaluatePredicate(reader, predicate, since, true, baselines)
|
|
528
565
|
.then(finish)
|
|
529
566
|
.catch((error) => {
|
|
530
567
|
finish(failed(error));
|
|
531
568
|
});
|
|
532
|
-
}
|
|
569
|
+
};
|
|
570
|
+
if (!holdsForAbsence) {
|
|
571
|
+
confirmTimer = setTimeout(confirm, COUNT_CONFIRM_MS);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
// An absence waits out ABSENCE_HOLD_MS, then for the page to go quiet. A settle read that
|
|
575
|
+
// could not answer is not a reason to hold on: the confirming read still decides.
|
|
576
|
+
const holdUntilQuiet = () => {
|
|
577
|
+
void evaluatePredicate(reader, SETTLED_PROBE, since, false)
|
|
578
|
+
.then((settled) => {
|
|
579
|
+
if (done)
|
|
580
|
+
return;
|
|
581
|
+
if (settled.pass) {
|
|
582
|
+
confirm();
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
confirmTimer = setTimeout(holdUntilQuiet, settled.retryAfterMs ?? POLL_INTERVAL_MS);
|
|
586
|
+
})
|
|
587
|
+
.catch(confirm);
|
|
588
|
+
};
|
|
589
|
+
confirmTimer = setTimeout(holdUntilQuiet, ABSENCE_HOLD_MS);
|
|
533
590
|
})
|
|
534
591
|
.catch((error) => {
|
|
535
592
|
finish(failed(error));
|
|
@@ -4,7 +4,7 @@ interface ReactionReport {
|
|
|
4
4
|
events: ReticleEvent[];
|
|
5
5
|
summary: ReactionSummary;
|
|
6
6
|
}
|
|
7
|
-
/** Turn a slice of the event buffer into the structured "what the app did" report
|
|
7
|
+
/** Turn a slice of the event buffer into the structured "what the app did" report. */
|
|
8
8
|
export declare function buildReactionReport(events: ReticleEvent[], windowMs: number): ReactionReport;
|
|
9
9
|
/**
|
|
10
10
|
* Drop the per-event `events` array, keeping the window and counts. The counts already answer "what
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventType, } from '@reticlehq/core';
|
|
2
|
-
/** Turn a slice of the event buffer into the structured "what the app did" report
|
|
2
|
+
/** Turn a slice of the event buffer into the structured "what the app did" report. */
|
|
3
3
|
export function buildReactionReport(events, windowMs) {
|
|
4
4
|
const summary = {
|
|
5
5
|
total: events.length,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/engine",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "The rules that decide a verdict: read what happened in a running app and say whether the declared consequence held. No browser, no daemon, no command line - an implementation of the OpenVerification specification you can use on its own.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verification",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"zod": "^3.24.1",
|
|
60
|
-
"@reticlehq/core": "3.
|
|
60
|
+
"@reticlehq/core": "3.6.0",
|
|
61
61
|
"open-verification": "1.0.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|